Add function for parsing a list from a config option

This commit is contained in:
Eric Torres 2019-04-14 22:15:00 -07:00
parent 0df6eafeaf
commit 1cc53f1178
2 changed files with 2 additions and 5 deletions

View File

@ -40,7 +40,7 @@ def get_files_by_suffix(suffix):
yield from CONFIG_DIR.glob(f"*{suffix}") yield from CONFIG_DIR.glob(f"*{suffix}")
def load_list_from_option(parser, *, section="", option="", fallback=list()): def load_list_from_option(parser, *, section="", option="", fallback=None):
"""Using a combination of ``ConfigParser`` and JSON, load a """Using a combination of ``ConfigParser`` and JSON, load a
list from a configuration file option. list from a configuration file option.
@ -53,7 +53,7 @@ def load_list_from_option(parser, *, section="", option="", fallback=list()):
:returns: the list parsed by JSON :returns: the list parsed by JSON
:param fallback: the fallback value to return if the option is empty :param fallback: the fallback value to return if the option is empty
:type fallback: list :type fallback: list
:rtype: list :rtype: list or type of fallback value
""" """
try: try:
return json.loads(parser[section][option]) return json.loads(parser[section][option])

View File

@ -12,12 +12,9 @@ _RSYNC_BIN = "/usr/bin/rsync"
DEFAULT_RSYNC_OPTS = [ DEFAULT_RSYNC_OPTS = [
"--acls", "--acls",
"--archive", "--archive",
"--backup",
"--backup-dir=backup",
"--hard-links", "--hard-links",
"--ignore-missing-args", "--ignore-missing-args",
"--prune-empty-dirs", "--prune-empty-dirs",
"--suffix=.old",
"--recursive", "--recursive",
"--xattrs", "--xattrs",
] ]