Run black over the entire project
Signed-off-by: Pierre-Yves Chibon <pingou@pingoured.fr>
This commit is contained in:
parent
d37f60b474
commit
392627ecab
4 changed files with 462 additions and 335 deletions
|
@ -23,17 +23,17 @@ import toml
|
|||
|
||||
|
||||
_here = os.path.dirname(__file__)
|
||||
_default_conf_root = os.path.join(_here, 'default-config-files')
|
||||
_system_conf_root = os.path.join(os.path.sep, 'etc', 'distgit-bugzilla-sync')
|
||||
_default_conf_root = os.path.join(_here, "default-config-files")
|
||||
_system_conf_root = os.path.join(os.path.sep, "etc", "distgit-bugzilla-sync")
|
||||
|
||||
config_files = {
|
||||
'default': {
|
||||
'configuration': os.path.join(_default_conf_root, 'configuration.toml'),
|
||||
'email_overrides': os.path.join(_default_conf_root, 'email_overrides.toml'),
|
||||
"default": {
|
||||
"configuration": os.path.join(_default_conf_root, "configuration.toml"),
|
||||
"email_overrides": os.path.join(_default_conf_root, "email_overrides.toml"),
|
||||
},
|
||||
'system': {
|
||||
'configuration': os.path.join(_system_conf_root, 'configuration.toml'),
|
||||
'email_overrides': os.path.join(_system_conf_root, 'email_overrides.toml'),
|
||||
"system": {
|
||||
"configuration": os.path.join(_system_conf_root, "configuration.toml"),
|
||||
"email_overrides": os.path.join(_system_conf_root, "email_overrides.toml"),
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -85,8 +85,10 @@ class ConfigDict(dict):
|
|||
self[k] = v
|
||||
|
||||
|
||||
def load_configuration(addl_config_files: Optional[Sequence[str]] = None,
|
||||
addl_email_overrides_files: Optional[Sequence[str]] = None):
|
||||
def load_configuration(
|
||||
addl_config_files: Optional[Sequence[str]] = None,
|
||||
addl_email_overrides_files: Optional[Sequence[str]] = None,
|
||||
):
|
||||
"""Load stored configuration.
|
||||
|
||||
This function loads default, system-wide, and if specified, additional
|
||||
|
@ -99,14 +101,14 @@ def load_configuration(addl_config_files: Optional[Sequence[str]] = None,
|
|||
|
||||
# Load default files.
|
||||
try:
|
||||
default_config = toml.load(config_files['default']['configuration'])
|
||||
default_config = toml.load(config_files["default"]["configuration"])
|
||||
except FileNotFoundError as e:
|
||||
raise RuntimeError(
|
||||
f"Default configuration file {config_files['default']['configuration']} not found."
|
||||
) from e
|
||||
|
||||
try:
|
||||
default_email_overrides = toml.load(config_files['default']['email_overrides'])
|
||||
default_email_overrides = toml.load(config_files["default"]["email_overrides"])
|
||||
except FileNotFoundError as e:
|
||||
raise RuntimeError(
|
||||
f"Default email overrides file {config_files['default']['email_overrides']} not found."
|
||||
|
@ -114,12 +116,12 @@ def load_configuration(addl_config_files: Optional[Sequence[str]] = None,
|
|||
|
||||
# Attempt to load system-wide files.
|
||||
try:
|
||||
system_config = toml.load(config_files['system']['configuration'])
|
||||
system_config = toml.load(config_files["system"]["configuration"])
|
||||
except FileNotFoundError:
|
||||
system_config = {}
|
||||
|
||||
try:
|
||||
system_email_overrides = toml.load(config_files['system']['email_overrides'])
|
||||
system_email_overrides = toml.load(config_files["system"]["email_overrides"])
|
||||
except FileNotFoundError:
|
||||
system_email_overrides = {}
|
||||
|
||||
|
@ -152,10 +154,10 @@ def load_configuration(addl_config_files: Optional[Sequence[str]] = None,
|
|||
email_overrides.update(system_email_overrides)
|
||||
email_overrides.update(addl_email_overrides)
|
||||
|
||||
for env in config['environments'].values():
|
||||
for env in config["environments"].values():
|
||||
# Fill environments with default data.
|
||||
env_values = copy.deepcopy(config)
|
||||
del env_values['environments']
|
||||
del env_values["environments"]
|
||||
|
||||
# Values specified in the environments should take precedence.
|
||||
env_values.update(env)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue