Clean up setters and getters in Config
This commit is contained in:
@@ -124,6 +124,17 @@ def checkUuid(value, default):
|
||||
return default
|
||||
|
||||
|
||||
def checkPath(value, default):
|
||||
"""Check if a value is a valid path. Non-empty strings are accepted.
|
||||
"""
|
||||
if isinstance(value, Path):
|
||||
return value
|
||||
elif isinstance(value, str):
|
||||
if value.strip():
|
||||
return Path(value)
|
||||
return default
|
||||
|
||||
|
||||
# =============================================================================================== #
|
||||
# Validator Functions
|
||||
# =============================================================================================== #
|
||||
@@ -552,6 +563,11 @@ class NWConfigParser(ConfigParser):
|
||||
logger.error("Could not read '%s':'%s' from config", section, option)
|
||||
return default
|
||||
|
||||
def rdPath(self, section, option, default):
|
||||
"""Read a path value.
|
||||
"""
|
||||
return checkPath(self.get(section, option, fallback=default), default)
|
||||
|
||||
def rdStrList(self, section, option, default):
|
||||
"""Read string list.
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user