(self, d, arg)
return arg
Convert argument to required type.
Convert argument to required type.
Convert argument to required type .
def _parse_type(self, d, arg):
        """Convert argument to required type."""
        if d not in ARGUMENTS:
            return arg
        if u'choices' in ARGUMENTS[d]:
            arg = arg.lower()
        first_arg = arg.split(u':')[0]
        if u'type' in ARGUMENTS[d]:
            if (ARGUMENTS[d][u'type'] == u'int'):
                arg = self._to_int(d, arg)
            elif (ARGUMENTS[d][u'type'] == u'bool'):
                arg = self._to_bool(d, arg)
        if u'choices' in ARGUMENTS[d]:
            if first_arg and first_arg not in ARGUMENTS[d][u'choices']:
                logging.warning(
                    u'Value `%s=%s` ignored; should be one of (`%s`)',
                    d, arg, u'`, `'.join(text_type(x) for x in ARGUMENTS[d][u'choices'])
                )
                arg = u''
        if u'check' in ARGUMENTS[d]:
            if arg and not ARGUMENTS[d][u'check'](first_arg):
                logging.warning(u'Value `%s=%s` ignored; not recognised', d, arg)
                arg = u''
        return arg
def _parse_type ( self , d , arg ) : if d not in ARGUMENTS : return arg if u'choices' in ARGUMENTS [ d ] : arg = arg . lower ( ) first_arg = arg . split ( u':' ) [ 0 ] if u'type' in ARGUMENTS [ d ] : if ( ARGUMENTS [ d ] [ u'type' ] == u'int' ) : arg = self . _to_int ( d , arg ) elif ( ARGUMENTS [ d ] [ u'type' ] == u'bool' ) : arg = self . _to_bool ( d , arg ) if u'choices' in ARGUMENTS [ d ] : if first_arg and first_arg not in ARGUMENTS [ d ] [ u'choices' ] : logging . warning ( u'Value `%s=%s` ignored; should be one of (`%s`)' , d , arg , u'`, `' . join ( text_type ( x ) for x in ARGUMENTS [ d ] [ u'choices' ] ) ) arg = u'' if u'check' in ARGUMENTS [ d ] : if arg and not ARGUMENTS [ d ] [ u'check' ] ( first_arg ) : logging . warning ( u'Value `%s=%s` ignored; not recognised' , d , arg ) arg = u'' return arg