Reformat function definitions with same indentation level
This commit is contained in:
parent
4ce2163e19
commit
ffb9e9d5f4
24
mvw-dl.py
24
mvw-dl.py
@ -76,7 +76,8 @@ log_connectionpool.setLevel(logging.WARNING)
|
||||
install(show_locals=True)
|
||||
|
||||
|
||||
class ConfigParser(configparser.ConfigParser):
|
||||
class ConfigParser(
|
||||
configparser.ConfigParser):
|
||||
"""Can get options() without defaults
|
||||
|
||||
Taken from https://stackoverflow.com/a/12600066.
|
||||
@ -98,11 +99,13 @@ config = ConfigParser(defaults=internal_defaults)
|
||||
config.read(CONST.CFG_DEFAULT_FILENAME)
|
||||
|
||||
|
||||
def print_section_header(header: str) -> str:
|
||||
def print_section_header(
|
||||
header: str) -> str:
|
||||
return f"Loading config section '[{header}]' ..."
|
||||
|
||||
|
||||
def validate_default_section(config_obj: configparser.ConfigParser()) -> None:
|
||||
def validate_default_section(
|
||||
config_obj: configparser.ConfigParser()) -> None:
|
||||
log.debug(f"Loading config from file '{CONST.CFG_DEFAULT_ABS_PATH}' ...")
|
||||
if not config_obj.sections():
|
||||
log.error(f"No config sections found in '{CONST.CFG_DEFAULT_ABS_PATH}'. Exiting 1 ...")
|
||||
@ -121,7 +124,8 @@ def validate_default_section(config_obj: configparser.ConfigParser()) -> None:
|
||||
log.debug(f"No defaults defined")
|
||||
|
||||
|
||||
def config_has_valid_section(config_obj: configparser.ConfigParser()) -> bool:
|
||||
def config_has_valid_section(
|
||||
config_obj: configparser.ConfigParser()) -> bool:
|
||||
has_valid_section = False
|
||||
for config_obj_section in config_obj.sections():
|
||||
if set(CONST.CFG_MANDATORY).issubset(config_obj.options(config_obj_section)):
|
||||
@ -130,15 +134,18 @@ def config_has_valid_section(config_obj: configparser.ConfigParser()) -> bool:
|
||||
return has_valid_section
|
||||
|
||||
|
||||
def is_default(config_key: str) -> bool:
|
||||
def is_default(
|
||||
config_key: str) -> bool:
|
||||
return any(config_key in ini_default for ini_default in ini_defaults)
|
||||
|
||||
|
||||
def is_same_as_default(config_kv_pair: dict) -> bool:
|
||||
def is_same_as_default(
|
||||
config_kv_pair: dict) -> bool:
|
||||
return config_kv_pair in ini_defaults
|
||||
|
||||
|
||||
def validate_config_sections(config_obj: configparser.ConfigParser()) -> None:
|
||||
def validate_config_sections(
|
||||
config_obj: configparser.ConfigParser()) -> None:
|
||||
for this_section in config_obj.sections():
|
||||
log.debug(print_section_header(this_section))
|
||||
if not set(CONST.CFG_MANDATORY).issubset(config_obj.options(this_section, no_defaults=True)):
|
||||
@ -155,7 +162,8 @@ def validate_config_sections(config_obj: configparser.ConfigParser()) -> None:
|
||||
log.debug(f"{kv_prefix} {key} = {config_obj[this_section][key]}")
|
||||
|
||||
|
||||
def query_string_from_file(filename: str) -> str:
|
||||
def query_string_from_file(
|
||||
filename: str) -> str:
|
||||
with open(filename, "r") as jsonfile:
|
||||
query_string = jsonfile.read()
|
||||
return query_string
|
||||
|
Loading…
x
Reference in New Issue
Block a user