diff options
author | André Erdmann <dywi@mailerd.de> | 2014-08-23 19:15:50 +0200 |
---|---|---|
committer | André Erdmann <dywi@mailerd.de> | 2014-08-23 19:15:50 +0200 |
commit | 7224fec5b78c8ac4c2c52d5615cc8ea42726c8a2 (patch) | |
tree | b0715d8d0ec0160389835240a31d851a2e89ff75 /roverlay | |
parent | roverlay 0.3.0 (diff) | |
download | R_overlay-7224fec5b78c8ac4c2c52d5615cc8ea42726c8a2.tar.gz R_overlay-7224fec5b78c8ac4c2c52d5615cc8ea42726c8a2.tar.bz2 R_overlay-7224fec5b78c8ac4c2c52d5615cc8ea42726c8a2.zip |
config loader, yesno(): use str_to_bool()
Diffstat (limited to 'roverlay')
-rw-r--r-- | roverlay/config/loader.py | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/roverlay/config/loader.py b/roverlay/config/loader.py index f5d28d8..76c73b0 100644 --- a/roverlay/config/loader.py +++ b/roverlay/config/loader.py @@ -17,7 +17,7 @@ import re import shlex import os.path -from roverlay.strutil import unquote +from roverlay.strutil import unquote, str_to_bool from roverlay.config import fielddef from roverlay.config.util import get_config_path from roverlay.config.entrymap import CONFIG_ENTRY_MAP @@ -365,15 +365,12 @@ class ConfigLoader ( object ): arguments: * val -- """ - if not val is None: - to_check = str ( val ).lower() - if to_check in [ 'y', 'yes', '1', 'true', 'enabled', 'on' ]: - return 1 - elif to_check in [ 'n', 'no', '0', 'false', 'disabled', 'off' ]: - return 0 - - self.logger.warning ( str(val) + " is not a valid yesno value." ) - return -1 + ret = str_to_bool ( val, nofail=True ) + if ret is None: + self.logger.warning ( str(val) + " is not a valid yesno value." ) + return -1 + else: + return int(ret) # --- end of yesno (...) --- def fs_path ( val ): |