Get a useful (and not too large) represetation of an argument.
485760
def _arg_repr(self, arg):
        
        r = repr(arg)
        max = 40
        if len(r) > max:
            if hasattr(arg, 'shape'):
                r = 'array:' + 'x'.join([repr(s) for s in arg.shape])
            else:
                r = r[:max-3] + '...'
        return r
757704
def make_arg(key, annotation=None):
    """"""
    arg = ast.arg(key, annotation)
    arg.lineno, arg.col_offset = 0, 0
    return arg
1054250
def get_arguments(self):
        """"""
        num_args = conf.lib.clang_Cursor_getNumArguments(self)
        for i in xrange(0, num_args):
            yield conf.lib.clang_Cursor_getArgument(self, i)
376351
def _es_args(self, resource, refresh=None, source_projections=None):
        """"""
        datasource = self.get_datasource(resource)
        args = {
            'index': self._resource_index(resource),
            'doc_type': datasource[0],
        }
        if source_projections:
            args['_source'] = source_projections
        if refresh:
            args['refresh'] = refresh

        return args
1250009
def __get_arg(cls, kwds, kwd):
    """"""
    alt_kwd = '_' + kwd
    if alt_kwd in kwds:
      return kwds.pop(alt_kwd)
    if kwd in kwds:
      obj = getattr(cls, kwd, None)
      if not isinstance(obj, Property) or isinstance(obj, ModelKey):
        return kwds.pop(kwd)
    return None
730861
def str_arg(d):
    """"""
    if not d:
        return None
    if isinstance(d, dict):
        if len(d) == 2 and d.get('type') == 'text' and 'value' in d:
            return str_arg(d['value'])
        if len(d) == 2 and d.get('type') == 'text' and 'subkey' in d:
            return ".%s" % d['subkey']
        if d.get('type') == 'module':
            return None
        return "{%s}" % str_args(d.items())
    if isinstance(d, list):
        if len(d) == 1:
            return str_arg(d[0])
        return "[%s]" % ", ".join(str_arg(elem) for elem in d)
    if isinstance(d, unicode):
        return '"%s"' % d

    return repr(d)
858013
def _argsdicts( args, mydict ):
    """"""
    
    if len( args ) == 0:
        args = None, 
    elif len( args ) == 1:
        args = _totuple( args[0] )
    else:
        raise Exception( "We should have never gotten here." )

    mykeys = list( mydict.keys( ) )
    myvalues = list( map( _totuple, list( mydict.values( ) ) ) )

    maxlength = max( list( map( len, [ args ] + myvalues ) ) )

    for i in range( maxlength ):
        thisdict = { }
        for key, value in zip( mykeys, myvalues ):
            try:
                thisdict[ key ] = value[i]
            except IndexError:
                thisdict[ key ] = value[-1]
        try:
            thisarg = args[i]
        except IndexError:
            thisarg = args[-1]

        yield thisarg, thisdict
1122367
def get_arg(context, index):
    """"""
    if index < len(context.argstreams):
        arg = ""
        chunk = yield context.argstreams[index].read()
        while chunk:
            arg += chunk
            chunk = yield context.argstreams[index].read()

        raise tornado.gen.Return(arg)
    else:
        raise TChannelError()
806382
def convert(self, argument):
    """"""
    if isinstance(argument, str):
      if argument.lower() in ['true', 't', '1']:
        return True
      elif argument.lower() in ['false', 'f', '0']:
        return False

    bool_argument = bool(argument)
    if argument == bool_argument:
      # The argument is a valid boolean (True, False, 0, or 1), and not just
      # something that always converts to bool (list, string, int, etc.).
      return bool_argument

    raise ValueError('Non-boolean argument to boolean flag', argument)
793326
def raise_null_argument(func):
    """"""
    def wrapper(*args, **kwargs):
        try:
            return func(*args, **kwargs)
        except TypeError as ex:
            if any(statement in ex.args[0] for statement in ['takes exactly',
                                                             'required positional argument']):
                raise NullArgument('Wrong number of arguments provided: ' + str(ex.args[0]))
            else:
                raise
    return wrapper
77607
def argval(self):
        
        if self.arg is None or any(x is None for x in self.arg):
            return None

        for x in self.arg:
            if not isinstance(x, int):
                raise InvalidArgError(self.arg)

        return self.arg
496187
def translate_resource_args(func):
    """"""
    @wraps(func)
    def wrapper(*args, **kwargs):
        """
        :type args: *Any
        :type kwargs: **Any
        :return: Any
        """
        arg_list = []
        for arg in args:
            if isinstance(arg, (Issue, Project)):
                arg_list.append(arg.key)
            else:
                arg_list.append(arg)
        result = func(*arg_list, **kwargs)
        return result

    return wrapper
1369743
def fn_minimum_argcount(callable):
    """"""
    fn = get_fn(callable)
    available_argcount = fn_available_argcount(callable)
    try:
        return available_argcount - len(fn.__defaults__)
    except TypeError:
        return available_argcount
1149949
def repr_arg(d):
    """"""
    if isinstance(d, dict):
        # if d can be expressed in key=value syntax:
        return "{%s}" % ", ".join(
            "%s: %s" % (repr_arg(k), repr_arg(v)) for k, v in d.items())
    if isinstance(d, list):
        return "[%s]" % ", ".join(repr_arg(elem) for elem in d)
    if isinstance(d, unicode):
        try:
            return repr(d.encode("ascii"))
        except UnicodeEncodeError:
            return repr(d)

    return repr(d)
191630
def r_to_s(func):
    """"""

    @functools.wraps(func)
    def wrapper(*args, **kwargs):
        """"""

        class ReprToStr(str):
            """Replaces a class __repr__ with it's string representation"""
            def __repr__(self):
                return str(self)
        return ReprToStr(func(*args, **kwargs))
    return wrapper
1131313
def args(self) -> str:
        """"""
        return '{}{}{}'.format(
            ChangeSpecialDeviceCommand.args,
            to_ascii_hex(encode_value_using_ma(self._message_attribute,
                                               self._control_high_limit), 2),
            to_ascii_hex(encode_value_using_ma(self._message_attribute,
                                               self._control_low_limit), 2))
1100668
def required_arguments(func):
    """"""
    defaults = default_values_of(func)
    args = arguments_of(func)

    if defaults:
        args = args[:-len(defaults)]
    return args