예제 #1
0
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
예제 #2
0
파일: __init__.py 프로젝트: stenwt/ansible
    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))
예제 #3
0
파일: __init__.py 프로젝트: dataxu/ansible
    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))
예제 #4
0
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
예제 #5
0
 def check_unquote(self, quoted, expected):
     tools.eq_(unquote(quoted), expected)
예제 #6
0
 def check_unquote(self, quoted, expected):
     tools.eq_(unquote(quoted), expected)