-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #75 from Zuehlke/rename-classes
Rename classes
- Loading branch information
Showing
32 changed files
with
364 additions
and
362 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,26 @@ | ||
from .change import depends_on | ||
from .confz import ConfZ | ||
from .confz_source import ( | ||
ConfZSources, | ||
ConfZSource, | ||
ConfZFileSource, | ||
ConfZEnvSource, | ||
ConfZCLArgSource, | ||
from .base_config import BaseConfig | ||
from .config_source import ( | ||
ConfigSources, | ||
ConfigSource, | ||
FileSource, | ||
EnvSource, | ||
CLArgSource, | ||
FileFormat, | ||
ConfZDataSource, | ||
DataSource, | ||
) | ||
from .validate import validate_all_configs | ||
|
||
|
||
__all__ = [ | ||
"depends_on", | ||
"ConfZ", | ||
"ConfZSources", | ||
"ConfZSource", | ||
"ConfZFileSource", | ||
"ConfZEnvSource", | ||
"ConfZCLArgSource", | ||
"BaseConfig", | ||
"ConfigSources", | ||
"ConfigSource", | ||
"FileSource", | ||
"EnvSource", | ||
"CLArgSource", | ||
"FileFormat", | ||
"ConfZDataSource", | ||
"DataSource", | ||
"validate_all_configs", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
class ConfZException(Exception): | ||
class ConfigException(Exception): | ||
"""The base exception. All other exceptions inherit from it.""" | ||
|
||
|
||
class ConfZUpdateException(ConfZException): | ||
class UpdateException(ConfigException): | ||
"""Exception which is raised if could not merge different config sources.""" | ||
|
||
|
||
class ConfZFileException(ConfZException): | ||
class FileException(ConfigException): | ||
"""Exception which is raised if something went wrong while reading a | ||
configuration file.""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,31 @@ | ||
import sys | ||
|
||
from confz.confz_source import ConfZCLArgSource | ||
from confz.config_source import CLArgSource | ||
from .loader import Loader | ||
|
||
|
||
class CLArgLoader(Loader): | ||
"""Config loader for command line arguments.""" | ||
|
||
@classmethod | ||
def populate_config(cls, config: dict, confz_source: ConfZCLArgSource): | ||
def populate_config(cls, config: dict, config_source: CLArgSource): | ||
cl_args = {} | ||
for idx, cl_arg in enumerate(sys.argv[1:]): | ||
if cl_arg.startswith("--") and idx + 2 < len(sys.argv): | ||
cl_name = cl_arg[2:] | ||
cl_value = sys.argv[idx + 2] | ||
|
||
if confz_source.prefix is not None: | ||
if not cl_name.startswith(confz_source.prefix): | ||
if config_source.prefix is not None: | ||
if not cl_name.startswith(config_source.prefix): | ||
continue | ||
cl_name = cl_name[len(confz_source.prefix) :] | ||
cl_name = cl_name[len(config_source.prefix) :] | ||
|
||
if confz_source.remap is not None and cl_name in confz_source.remap: | ||
cl_name = confz_source.remap[cl_name] | ||
if config_source.remap is not None and cl_name in config_source.remap: | ||
cl_name = config_source.remap[cl_name] | ||
|
||
cl_args[cl_name] = cl_value | ||
|
||
cl_args = cls.transform_nested_dicts( | ||
cl_args, separator=confz_source.nested_separator | ||
cl_args, separator=config_source.nested_separator | ||
) | ||
cls.update_dict_recursively(config, cl_args) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
from confz.confz_source import ConfZDataSource | ||
from confz.config_source import DataSource | ||
from .loader import Loader | ||
|
||
|
||
class DataLoader(Loader): | ||
"""Config loader for fix data.""" | ||
|
||
@classmethod | ||
def populate_config(cls, config: dict, confz_source: ConfZDataSource): | ||
cls.update_dict_recursively(config, confz_source.data) | ||
def populate_config(cls, config: dict, config_source: DataSource): | ||
cls.update_dict_recursively(config, config_source.data) |
Oops, something went wrong.