Commit 622c25a8 authored by Vincent Michel's avatar Vincent Michel
Browse files

Make the file API more flexible

parent e2e754cf
......@@ -406,8 +406,9 @@ def get_handel_version():
# Files
def get_config_files(path):
def get_config_files(*path):
"""Return all the ini files in path (including subdirectories)."""
path = os.path.join(*path)
ext = b'.ini' if isinstance(path, bytes) else '.ini'
sep = b'/' if isinstance(path, bytes) else '/'
return [os.path.join(dp, f).lstrip(path).lstrip(sep)
......@@ -416,8 +417,8 @@ def get_config_files(path):
if f.endswith(ext)]
def get_config(path, filename):
def get_config(*path):
"""Read and return the given config file as a dictionary."""
filename = os.path.join(path, filename)
filename = os.path.join(*path)
with open(filename) as f:
return parse_xia_ini_file(f.read())
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment