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)
|
install(show_locals=True)
|
||||||
|
|
||||||
|
|
||||||
class ConfigParser(configparser.ConfigParser):
|
class ConfigParser(
|
||||||
|
configparser.ConfigParser):
|
||||||
"""Can get options() without defaults
|
"""Can get options() without defaults
|
||||||
|
|
||||||
Taken from https://stackoverflow.com/a/12600066.
|
Taken from https://stackoverflow.com/a/12600066.
|
||||||
@ -98,11 +99,13 @@ config = ConfigParser(defaults=internal_defaults)
|
|||||||
config.read(CONST.CFG_DEFAULT_FILENAME)
|
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}]' ..."
|
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}' ...")
|
log.debug(f"Loading config from file '{CONST.CFG_DEFAULT_ABS_PATH}' ...")
|
||||||
if not config_obj.sections():
|
if not config_obj.sections():
|
||||||
log.error(f"No config sections found in '{CONST.CFG_DEFAULT_ABS_PATH}'. Exiting 1 ...")
|
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")
|
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
|
has_valid_section = False
|
||||||
for config_obj_section in config_obj.sections():
|
for config_obj_section in config_obj.sections():
|
||||||
if set(CONST.CFG_MANDATORY).issubset(config_obj.options(config_obj_section)):
|
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
|
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)
|
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
|
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():
|
for this_section in config_obj.sections():
|
||||||
log.debug(print_section_header(this_section))
|
log.debug(print_section_header(this_section))
|
||||||
if not set(CONST.CFG_MANDATORY).issubset(config_obj.options(this_section, no_defaults=True)):
|
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]}")
|
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:
|
with open(filename, "r") as jsonfile:
|
||||||
query_string = jsonfile.read()
|
query_string = jsonfile.read()
|
||||||
return query_string
|
return query_string
|
||||||
|
Loading…
x
Reference in New Issue
Block a user