Extend config options

This commit is contained in:
hygienic-books 2022-03-22 02:33:57 +01:00
parent ec05611ee3
commit 5224c90918
2 changed files with 21 additions and 3 deletions

View File

@ -1,3 +1,15 @@
[DEFAULT]
self_name = kodi-nfo-feeder
ignored_target_file_exts = .jpg, .jpeg, .png, .nfo
title_regex_search =
title_regex_replace =
[maus] [maus]
watch_dir = /var/lib/kodi-nfo-feeder/watch watch_dir = /var/lib/kodi-nfo-feeder/watch
output_dir = /var/lib/kodi-nfo-feeder/output output_dir = /var/lib/kodi-nfo-feeder/output
# title_regex_search = (\w)-(\s)
# title_regex_replace = \1 -\2
[otto]
watch_dir = /var/lib/kodi-nfo-feeder/test/watch
output_dir = /var/lib/kodi-nfo-feeder/test/output

View File

@ -22,11 +22,15 @@ class CONST(object):
CFG_DEFAULT_ABS_PATH = os.path.join(CFG_THIS_FILE_DIRNAME, CFG_DEFAULT_FILENAME) CFG_DEFAULT_ABS_PATH = os.path.join(CFG_THIS_FILE_DIRNAME, CFG_DEFAULT_FILENAME)
CFG_KNOWN_DEFAULTS = [ CFG_KNOWN_DEFAULTS = [
{"key": "self_name", "value": "kodi-nfo-feeder"}, {"key": "self_name", "value": "kodi-nfo-feeder"},
{"key": "watch_dir", "value": os.path.join(CFG_THIS_FILE_DIRNAME, "data/var/lib/%(self_name)s/watch")} {"key": "ignored_target_file_exts", "value": ".jpg, .jpeg, .png, .nfo"},
{"key": "title_regex_search", "value": ""},
{"key": "title_regex_replace", "value": ""}
] ]
CFG_KNOWN_SECTION = [ CFG_KNOWN_SECTION = [
{"key": "watch_dir", "is_mandatory": True}, {"key": "watch_dir", "is_mandatory": True},
{"key": "output_dir", "is_mandatory": True} {"key": "output_dir", "is_mandatory": True},
{"key": "title_regex_search", "is_mandatory": False},
{"key": "title_regex_replace", "is_mandatory": False}
] ]
CFG_MANDATORY = [section_cfg["key"] for section_cfg in CFG_KNOWN_SECTION if section_cfg["is_mandatory"]] CFG_MANDATORY = [section_cfg["key"] for section_cfg in CFG_KNOWN_SECTION if section_cfg["is_mandatory"]]
@ -71,6 +75,8 @@ ini_defaults = []
internal_defaults = {default["key"]: default["value"] for default in CONST.CFG_KNOWN_DEFAULTS} internal_defaults = {default["key"]: default["value"] for default in CONST.CFG_KNOWN_DEFAULTS}
config = ConfigParser(defaults=internal_defaults) config = ConfigParser(defaults=internal_defaults)
config.read(CONST.CFG_DEFAULT_FILENAME) config.read(CONST.CFG_DEFAULT_FILENAME)
ignored_target_file_exts_str = config.get(config.default_section, "ignored_target_file_exts")
ignored_target_file_exts = re.split(r""",\s?|\s""", ignored_target_file_exts_str)
def print_section_header( def print_section_header(