mirror of
https://github.com/thatmattlove/hyperglass.git
synced 2026-01-17 08:48:05 +00:00
Return an empty config if a file is missing and not required
This commit is contained in:
parent
aaad4d9350
commit
38e5d486b8
1 changed files with 7 additions and 1 deletions
|
|
@ -112,10 +112,16 @@ def load_python(path: Path, *, empty_allowed: bool) -> LoadedConfig:
|
|||
def load_config(name: str, *, required: bool) -> LoadedConfig:
|
||||
"""Load a configuration file."""
|
||||
path = find_path(name, required=required)
|
||||
if path.suffix == ".py":
|
||||
|
||||
if path is None and required is False:
|
||||
return {}
|
||||
|
||||
elif path.suffix == ".py":
|
||||
return load_python(path, empty_allowed=not required)
|
||||
|
||||
elif path.suffix.replace(".", "") in CONFIG_EXTENSIONS:
|
||||
return load_dsl(path, empty_allowed=not required)
|
||||
|
||||
raise ConfigError(
|
||||
"{p} has an unsupported file extension. Must be one of {e}",
|
||||
p=path,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue