mirror of
ssh://git.janware.com/srv/git/janware/proj/jw-python
synced 2026-01-15 09:53:32 +01:00
Config: Accept strings as value for glob_paths
Make Config's ctor accept strings as values for glob_paths, as opposed to lists. This covers the canonical case of one configuration file being passed. Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
2ec6e72cff
commit
bee3e28ff5
1 changed files with 3 additions and 1 deletions
|
|
@ -28,6 +28,8 @@ class Config(): # export
|
|||
exe = Path(os.path.basename(sys.argv[0])).stem
|
||||
if glob_paths is None:
|
||||
glob_paths = [f'.{exe}', f'{exe}.conf']
|
||||
elif isinstance(glob_paths, str):
|
||||
glob_paths = [glob_paths]
|
||||
if search_dirs is None:
|
||||
env_key = re.sub('[-.]', '_', exe)
|
||||
search_dirs = os.getenv(env_key)
|
||||
|
|
@ -36,7 +38,7 @@ class Config(): # export
|
|||
if dirs is None:
|
||||
dirs = [''] if __is_abs(path) else [ str(Path.home()), str(Path.cwd()) ]
|
||||
for d in dirs:
|
||||
g = d + '/' + path
|
||||
g = d + '/' + path if len(d) else path
|
||||
slog(DEBUG, 'Looking for config "{}"'.format(g))
|
||||
for f in glob.glob(g):
|
||||
slog(DEBUG, 'Reading config "{}"'.format(f))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue