Python 2 only. Lookup given *arg* and convert its str or unicode value according to MODERNRPC_PY2_STR_TYPE and
    MODERNRPC_PY2_STR_ENCODING settings.
968465
def standardize_strings(arg, strtype=settings.MODERNRPC_PY2_STR_TYPE, encoding=settings.MODERNRPC_PY2_STR_ENCODING):
    
    assert six.PY2, "This function should be used with Python 2 only"

    if not strtype:
        return arg

    if strtype == six.binary_type or strtype == 'str':
        # We want to convert from unicode to str
        return _generic_convert_string(arg, six.text_type, six.binary_type, encoding)

    elif strtype == six.text_type or strtype == 'unicode':
        # We want to convert from str to unicode
        return _generic_convert_string(arg, six.binary_type, six.text_type, encoding)

    raise TypeError('standardize_strings() called with an invalid strtype: "{}". Allowed values: str or unicode'
                    .format(repr(strtype)))
901872
def type_check_and_str(python_type, value):
    """"""
    if not isinstance(value, python_type):
        raise GraphQLInvalidArgumentError(u'Attempting to represent a non-{type} as a {type}: '
                                          u'{value}'.format(type=python_type, value=value))

    return str(value)
1281957
def arg_check(args, types = nil, server = nil)
      return args unless types

      args.each_with_index.map do |arg, i|
        next arg if types[i].nil? || types[i] == String

        if types[i] == Integer
          begin
            Integer(arg)
          rescue ArgumentError
            nil
          end
        elsif types[i] == Float
          begin
            Float(arg)
          rescue ArgumentError
            nil
          end
        elsif types[i] == Time
          begin
            Time.parse arg
          rescue ArgumentError
            nil
          end
        elsif types[i] == TrueClass || types[i] == FalseClass
          if arg.casecmp('true').zero? || arg.downcase.start_with?('y')
            true
          elsif arg.casecmp('false').zero? || arg.downcase.start_with?('n')
            false
          end
        elsif types[i] == Symbol
          arg.to_sym
        elsif types[i] == Encoding
          begin
            Encoding.find arg
          rescue ArgumentError
            nil
          end
        elsif types[i] == Regexp
          begin
            Regexp.new arg
          rescue ArgumentError
            nil
          end
        elsif types[i] == Rational
          begin
            Rational(arg)
          rescue ArgumentError
            nil
          end
        elsif types[i] == Range
          begin
            if arg.include? '...'
              Range.new(*arg.split('...').map(&:to_i), true)
            elsif arg.include? '..'
              Range.new(*arg.split('..').map(&:to_i))
            end
          rescue ArgumentError
            nil
          end
        elsif types[i] == NilClass
          nil
        elsif [Discordrb::User, Discordrb::Role, Discordrb::Emoji].include? types[i]
          result = parse_mention arg, server
          result if result.instance_of? types[i]
        elsif types[i] == Discordrb::Invite
          resolve_invite_code arg
        elsif types[i].respond_to?(:from_argument)
          begin
            types[i].from_argument arg
          rescue StandardError
            nil
          end
        else
          raise ArgumentError, "#{types[i]} doesn't implement from_argument"
        end
      end
    end
1108145
def p_str(p):
    
    if is_number(p[2]):  # A constant is converted to string directly
        p[0] = symbols.STRING(str(p[2].value), p.lineno(1))
    else:
        p[0] = make_builtin(p.lineno(1), 'STR',
                            make_typecast(TYPE.float_, p[2], p.lineno(1)),
                            type_=TYPE.string)
652960
def unicoder(p):
    
    if isinstance(p, unicode):
        return p
    if isinstance(p, str):
        return decoder(p)
    else:
        return unicode(decoder(p))
925223
def args_str(self):
        
        matched = [str(m) for m in self._used_matchers]
        unmatched = [str(m) for m in self._unused_matchers]
        return 'matched=[{}], unmatched=[{}]'.format(
            ', '.join(matched), ', '.join(unmatched))
949795
def safeunicode(arg, *args, **kwargs):
	""""""
	return arg if isinstance(arg, unicode) else unicode(arg, *args, **kwargs)
331045
def arg_to_soql(arg):
    
    conversion = sql_conversions.get(type(arg))
    if conversion:
        return conversion(arg)
    for type_ in subclass_conversions:
        if isinstance(arg, type_):
            return sql_conversions[type_](arg)
    return sql_conversions[str](arg)
1066791
def _safe_match_argument(expected_type, argument_value):
    """"""
    if GraphQLString.is_same_type(expected_type):
        return _safe_match_string(argument_value)
    elif GraphQLID.is_same_type(expected_type):
        # IDs can be strings or numbers, but the GraphQL library coerces them to strings.
        # We will follow suit and treat them as strings.
        if not isinstance(argument_value, six.string_types):
            if isinstance(argument_value, bytes):  # should only happen in py3
                argument_value = argument_value.decode('utf-8')
            else:
                argument_value = six.text_type(argument_value)
        return _safe_match_string(argument_value)
    elif GraphQLFloat.is_same_type(expected_type):
        return represent_float_as_str(argument_value)
    elif GraphQLInt.is_same_type(expected_type):
        # Special case: in Python, isinstance(True, int) returns True.
        # Safeguard against this with an explicit check against bool type.
        if isinstance(argument_value, bool):
            raise GraphQLInvalidArgumentError(u'Attempting to represent a non-int as an int: '
                                              u'{}'.format(argument_value))
        return type_check_and_str(int, argument_value)
    elif GraphQLBoolean.is_same_type(expected_type):
        return type_check_and_str(bool, argument_value)
    elif GraphQLDecimal.is_same_type(expected_type):
        return _safe_match_decimal(argument_value)
    elif GraphQLDate.is_same_type(expected_type):
        return _safe_match_date_and_datetime(expected_type, (datetime.date,), argument_value)
    elif GraphQLDateTime.is_same_type(expected_type):
        return _safe_match_date_and_datetime(expected_type,
                                             (datetime.datetime, arrow.Arrow), argument_value)
    elif isinstance(expected_type, GraphQLList):
        return _safe_match_list(expected_type.of_type, argument_value)
    else:
        raise AssertionError(u'Could not safely represent the requested GraphQL type: '
                             u'{} {}'.format(expected_type, argument_value))
841291
def do_pp(self, arg):
        
        obj = self._getval(arg)
        try:
            repr(obj)
        except Exception:
            self.message(bdb.safe_repr(obj))
        else:
            self.message(pprint.pformat(obj))
1190733
def format_arg(value):
    
    translator = repr if isinstance(value, six.string_types) else six.text_type
    return translator(value)
728966
def _convert_args(args):
    '''
    
    '''
    converted = []
    for arg in args:
        if isinstance(arg, dict):
            for key in list(arg.keys()):
                if key == '__kwarg__':
                    continue
                converted.append('{0}={1}'.format(key, arg[key]))
        else:
            converted.append(arg)
    return converted
973588
def prepare_arg(value):
    
    if value is None:
        return value
    elif isinstance(value, (list, dict)) or hasattr(value, 'to_python'):
        return json.dumps(_normalize(value))
    elif isinstance(value, datetime.timedelta):
        now = datetime.datetime.now()
        return int((now + value).timestamp())
    elif isinstance(value, datetime.datetime):
        return round(value.timestamp())
    elif isinstance(value, LazyProxy):
        return str(value)
    return value
391306
private SemanticStatus argumentsMatch(final String arg1, final String arg2) {

        if (arg1.startsWith(ENCODE_PREFIX)) {
            if (arg2.startsWith(FUNC_PREFIX)) {
                return INVALID_RETURN_TYPE_ARGUMENT;
            }
            if (!arg2.startsWith(ENCODE_PREFIX)) {
                return INVALID_ENCODING_ARGUMENT;
            }

            final String[] tokens1 = PARAMS_REGEX.split(arg1);
            if (tokens1.length != 2) {
                return INVALID_ENCODING_ARGUMENT;
            }

            final String[] tokens2 = PARAMS_REGEX.split(arg2);
            if (tokens2.length != 2) {
                return INVALID_ENCODING_ARGUMENT;
            }

            // If either token is the wildcard, any encoding is valid.
            if (isWildcard(tokens1[1]) || isWildcard(tokens2[1])) {
                return VALID;
            }

            final ValueEncoding ve1 = getValueEncoding(tokens1[1]);
            ValueEncoding ve2 = getValueEncoding(tokens2[1]);
            if (ve2 != null) {
                if (ve1.isAssignableFrom(ve2)) {
                    return VALID;
                }
                return INVALID_ENCODING_ARGUMENT;
            }
            // Fallback to verification based on all character discriminators
            for (final Character c : tokens2[1].toCharArray()) {
                ve2 = getValueEncoding(c);
                if (ve1.isAssignableFrom(ve2)) {
                    return VALID;
                }
            }
            return INVALID_ENCODING_ARGUMENT;
        }

        if (arg1.startsWith(FUNC_PREFIX)) {
            if (arg2.startsWith(ENCODE_PREFIX))
                return INVALID_RETURN_TYPE_ARGUMENT;
            if (!arg2.startsWith(FUNC_PREFIX))
                return INVALID_RETURN_TYPE_ARGUMENT;

            final String[] tokens1 = PARAMS_REGEX.split(arg1);
            if (tokens1.length != 2)
                return INVALID_RETURN_TYPE_ARGUMENT;

            final String[] tokens2 = PARAMS_REGEX.split(arg2);
            if (tokens2.length != 2)
                return INVALID_RETURN_TYPE_ARGUMENT;

            final ReturnType re1 = ReturnType.getReturnType(tokens1[1]);
            final ReturnType re2 = ReturnType.getReturnType(tokens2[1]);

            if (re1 != re2 && !re1.isAssignableFrom(re2))
                return INVALID_RETURN_TYPE_ARGUMENT;
            return VALID;
        }

        return null;
    }
679169
def get_value(self, key, args, kwargs):
        """"""
        if (self.tolerant and
                not isinstance(key, basestring) and
                key not in kwargs):
            key = str(key)

        return kwargs[key]
655792
def get_name_arg(argd, *argnames, default=None):
    
    val = None
    for argname in argnames:
        if argd[argname]:
            val = argd[argname].lower().strip()
            break
    return val if val else default
590929
def validate_args(opts):
    """"""
    if opts['--wide'] is None:
        opts['--wide'] = 2
    else:
        assert opts['--wide'] in ("1", "2"), opts['--wide']
    if opts['--alignment'] is None:
        opts['--alignment'] = 'left'
    else:
        assert opts['--alignment'] in ('left', 'right'), opts['--alignment']
    opts['--wide'] = int(opts['--wide'])
    opts['character_factory'] = WcWideCharacterGenerator
    if opts['--combining']:
        opts['character_factory'] = WcCombinedCharacterGenerator
    return opts