mirror of
ssh://git.janware.com/srv/git/janware/proj/jw-python
synced 2026-01-15 01:52:56 +01:00
Config: Support glob_paths_env_key
Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
495cebd769
commit
34de9114c5
1 changed files with 18 additions and 3 deletions
|
|
@ -63,18 +63,33 @@ class Config(): # export
|
||||||
ret.add("", tree)
|
ret.add("", tree)
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
def __init__(self, search_dirs: Optional[list[str]]=None, glob_paths: Optional[list[str]]=None,
|
def __init__(self,
|
||||||
defaults: Optional[Dict[str, str]]=None, tree: Optional[StringTree]=None, parent=None,
|
search_dirs: Optional[list[str]]=None,
|
||||||
root_section=None, refuse_mode_mask=0o0027) -> None:
|
glob_paths: Optional[list[str]]=None,
|
||||||
|
glob_paths_env_key: Optional[str]=None,
|
||||||
|
defaults: Optional[Dict[str, str]]=None,
|
||||||
|
tree: Optional[StringTree]=None,
|
||||||
|
parent=None,
|
||||||
|
root_section=None,
|
||||||
|
refuse_mode_mask=0o0027
|
||||||
|
) -> None:
|
||||||
|
|
||||||
self.__parent = parent
|
self.__parent = parent
|
||||||
|
|
||||||
if tree is not None:
|
if tree is not None:
|
||||||
assert(search_dirs is None)
|
assert(search_dirs is None)
|
||||||
assert(glob_paths is None)
|
assert(glob_paths is None)
|
||||||
|
assert(glob_paths_env_key is None)
|
||||||
self.__conf = tree
|
self.__conf = tree
|
||||||
else:
|
else:
|
||||||
assert(tree is None)
|
assert(tree is None)
|
||||||
|
if glob_paths_env_key is not None:
|
||||||
|
glob_paths_env = os.getenv(glob_paths_env_key)
|
||||||
|
if glob_paths_env is not None:
|
||||||
|
if glob_paths is None:
|
||||||
|
glob_paths = []
|
||||||
|
glob_paths.extend(glob_paths_env.split(':'))
|
||||||
|
|
||||||
self.__conf = self.__load(search_dirs=search_dirs, glob_paths=glob_paths,
|
self.__conf = self.__load(search_dirs=search_dirs, glob_paths=glob_paths,
|
||||||
refuse_mode_mask=refuse_mode_mask)
|
refuse_mode_mask=refuse_mode_mask)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue