Return the signature contents of a callable Python object.
970645
def _callable_contents(obj):
    
    try:
        # Test if obj is a method.
        return _function_contents(obj.__func__)

    except AttributeError:
        try:
            # Test if obj is a callable object.
            return _function_contents(obj.__call__.__func__)

        except AttributeError:
            try:
                # Test if obj is a code object.
                return _code_contents(obj)

            except AttributeError:
                # Test if obj is a function object.
                return _function_contents(obj)
1268020
def object_annotation(obj):
    
    # For basic types, use the repr.
    if isinstance(obj, BASE_TYPES):
        return repr(obj)
    if type(obj).__name__ == 'function':
        return "function\\n{}".format(obj.__name__)
    elif isinstance(obj, types.MethodType):
        if six.PY2:
            im_class = obj.im_class
            if im_class is None:
                im_class_name = "<None>"
            else:
                im_class_name = im_class.__name__

            try:
                func_name = obj.__func__.__name__
            except AttributeError:
                func_name = "<anonymous>"
            return "instancemethod\\n{}.{}".format(
                im_class_name,
                func_name,
            )
        else:
            try:
                func_name = obj.__func__.__qualname__
            except AttributeError:
                func_name = "<anonymous>"
            return "instancemethod\\n{}".format(func_name)
    elif isinstance(obj, list):
        return "list[{}]".format(len(obj))
    elif isinstance(obj, tuple):
        return "tuple[{}]".format(len(obj))
    elif isinstance(obj, dict):
        return "dict[{}]".format(len(obj))
    elif isinstance(obj, types.ModuleType):
        return "module\\n{}".format(obj.__name__)
    elif isinstance(obj, type):
        return "type\\n{}".format(obj.__name__)
    elif six.PY2 and isinstance(obj, types.InstanceType):
        return "instance\\n{}".format(obj.__class__.__name__)
    elif isinstance(obj, weakref.ref):
        referent = obj()
        if referent is None:
            return "weakref (dead referent)"
        else:
            return "weakref to id 0x{:x}".format(id(referent))
    elif isinstance(obj, types.FrameType):
        filename = obj.f_code.co_filename
        if len(filename) > FRAME_FILENAME_LIMIT:
            filename = "..." + filename[-(FRAME_FILENAME_LIMIT-3):]
        return "frame\\n{}:{}".format(
            filename,
            obj.f_lineno,
        )
    else:
        return "object\\n{}.{}".format(
            type(obj).__module__,
            type(obj).__name__,
        )
367301
def _get_callable_full_name(self, fob, fin, uobj):
        """"""
        # Check if object is a class property
        name = self._property_search(fob)
        if name:
            del fob, fin, uobj
            return name
        if os.path.isfile(fin):
            lineno = fob.f_lineno
            ret = self._callables_obj.get_callable_from_line(fin, lineno)
            del fob, fin, uobj, name, lineno
            return ret
        # Code executed in doctests does not have an actual callable object
        # exec-based callables do not have a valid file name
        fname = uobj and _get_func_code(uobj).co_filename
        if (not fname) or (fname and (not os.path.isfile(fname))):
            del fob, fin, uobj, name, fname
            return "dynamic"
        code_id = (
            inspect.getfile(uobj).replace(".pyc", "py"),
            inspect.getsourcelines(uobj)[1],
        )
        self._callables_obj.trace([code_id[0]])
        ret = self._callables_obj.reverse_callables_db[code_id]
        del fob, fin, uobj, name, fname, code_id
        return ret
1180445
def _object_contents(obj):
    
    try:
        # Test if obj is a method.
        return _function_contents(obj.__func__)

    except AttributeError:
        try:
            # Test if obj is a callable object.
            return _function_contents(obj.__call__.__func__)

        except AttributeError:
            try:
                # Test if obj is a code object.
                return _code_contents(obj)

            except AttributeError:
                try:
                    # Test if obj is a function object.
                    return _function_contents(obj)

                except AttributeError as ae:
                    # Should be a pickle-able Python object.
                    try:
                        return _object_instance_content(obj)
                        # pickling an Action instance or object doesn't yield a stable
                        # content as instance property may be dumped in different orders
                        # return pickle.dumps(obj, ACTION_SIGNATURE_PICKLE_PROTOCOL)
                    except (pickle.PicklingError, TypeError, AttributeError) as ex:
                        # This is weird, but it seems that nested classes
                        # are unpickable. The Python docs say it should
                        # always be a PicklingError, but some Python
                        # versions seem to return TypeError.  Just do
                        # the best we can.
                        return bytearray(repr(obj), 'utf-8')
123569
def props(cls):
    
    return {k:v for (k, v) in inspect.getmembers(cls) if type(v) is Argument}
104521
def get_callproc_signature(self, name, param_types):
    
    if isinstance(param_types[0], (list, tuple)):
      params = [self.sql_writer.to_placeholder(*pt) for pt in param_types]
    else:
      params = [self.sql_writer.to_placeholder(None, pt) for pt in param_types]

    return name + self.sql_writer.to_tuple(params)
1183012
def contents(self):
        """"""
        if not IS_PY2 and isinstance(self.byte_contents, bytes):
            return self.byte_contents.decode(
                self.encoding or locale.getpreferredencoding(False),
                errors=self.errors)
        return self.byte_contents
1105684
def _build_signature(self, run_args):
    """"""
    return (id(run_args.fct), run_args.input.dtype, run_args.input.shape)
1287917
def _get_signature_object(func, as_instance, eat_self):
    
    if isinstance(func, ClassTypes) and not as_instance:
        # If it's a type and should be modelled as a type, use __init__.
        try:
            func = func.__init__
        except AttributeError:
            return None
        # Skip the `self` argument in __init__
        eat_self = True
    elif not isinstance(func, FunctionTypes):
        # If we really want to model an instance of the passed type,
        # __call__ should be looked up, not __init__.
        try:
            func = func.__call__
        except AttributeError:
            return None
    if eat_self:
        sig_func = partial(func, None)
    else:
        sig_func = func

    try:
        return func, inspectsignature(sig_func)
    except ValueError:
        # Certain callable types are not supported by inspect.signature()
        return None
1227702
def signature(self, block_size=None):
        ""
        kwargs = {}
        if block_size:
            kwargs['block_size'] = block_size
        return librsync.signature(open(self.path, 'rb'), **kwargs)
515484
def get_signature_from_signature_string(self, signature):
        """"""
        match = self.SIGNATURE_RE.search(signature)
        if not match:
            return None
        return match.group(1)
1095915
def _if_not_freed(f):
    """"""
    @add_signature_to_docstring(f)
    @functools.wraps(f)
    def f_(self, *args, **kwargs):
        if self._freed:
            raise OSError
        return f(self, *args, **kwargs)

    return f_
860765
def wraplet_signature(app, what, name, obj, options, signature, return_annotation):
    """"""
    try:
        wrapped = obj._raw_slave
    except AttributeError:
        return None
    else:
        slave_argspec = autodoc.getargspec(wrapped)
        slave_signature = autodoc.formatargspec(obj, *slave_argspec)
        return (slave_signature, return_annotation)
1225355
def _dump_impl():
    # type: () -> List[FunctionData]
    """"""
    filtered_signatures = _filter_types(collected_signatures)
    sorted_by_file = sorted(iteritems(filtered_signatures),
                            key=(lambda p: (p[0].path, p[0].line, p[0].func_name)))
    res = []  # type: List[FunctionData]
    for function_key, signatures in sorted_by_file:
        comments = [_make_type_comment(args, ret_type) for args, ret_type in signatures]
        res.append(
            {
                'path': function_key.path,
                'line': function_key.line,
                'func_name': function_key.func_name,
                'type_comments': comments,
                'samples': num_samples.get(function_key, 0),
            }
        )
    return res
893044
def fmt_repr(obj):
  
  items = {k: v for k, v in list(obj.__dict__.items())}
  return "<%s: {%s}>" % (obj.__class__.__name__, pprint.pformat(items, width=1))
1004284
def signature(self):
        
        return self.name, [str(x.type) for x in self.parameters], [str(x.type) for x in self.returns]
341759
def get_signature_string(params, secret):
    
    str_list = [str(item) for item in extract_params(params)]
    str_list.sort()
    return (secret + ''.join(str_list)).encode('utf-8')