def get_config(p, section, key, env_var, default, boolean=False, integer=False, floating=False, islist=False, isnone=False, ispath=False): ''' return a configuration variable with casting ''' value = _get_config(p, section, key, env_var, default) if boolean: value = mk_boolean(value) if value: if integer: value = int(value) elif floating: value = float(value) elif islist: if isinstance(value, string_types): value = [x.strip() for x in value.split(',')] elif isnone: if value == "None": value = None elif ispath: value = shell_expand(value) elif isinstance(value, string_types): value = unquote(value) return value
def path_dwim(self, given): ''' make relative paths work like folks expect. ''' given = unquote(given) if given.startswith("/"): return os.path.abspath(given) elif given.startswith("~"): return os.path.abspath(os.path.expanduser(given)) else: return os.path.abspath(os.path.join(self._basedir, given))
def path_dwim(self, given): ''' make relative paths work like folks expect. ''' given = unquote(given) if given.startswith("/"): return os.path.abspath(given) elif given.startswith("~"): return os.path.abspath(os.path.expanduser(given)) else: return os.path.abspath(os.path.join(self._basedir, given))
def get_config(p, section, key, env_var, default, boolean=False, integer=False, floating=False, islist=False, isnone=False, ispath=False): ''' return a configuration variable with casting ''' value = _get_config(p, section, key, env_var, default) if boolean: value = mk_boolean(value) if value: if integer: value = int(value) elif floating: value = float(value) elif islist: if isinstance(value, string_types): value = [x.strip() for x in value.split(',')] elif isnone: if value == "None": value = None elif ispath: value = shell_expand(value) elif isinstance(value, string_types): value = unquote(value) return value
def check_unquote(self, quoted, expected): tools.eq_(unquote(quoted), expected)
def check_unquote(self, quoted, expected): tools.eq_(unquote(quoted), expected)