当前位置: 首页>>代码示例>>Python>>正文


Python six.get_method_function函数代码示例

本文整理汇总了Python中six.get_method_function函数的典型用法代码示例。如果您正苦于以下问题:Python get_method_function函数的具体用法?Python get_method_function怎么用?Python get_method_function使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了get_method_function函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: executeMethod

    def executeMethod(self, interfaceObj, methodName, methodArguments, sender):
        m = getattr(self, 'dbus_' + methodName, None)

        iname = interfaceObj.name
        
        if m is None:
            m = self._getDecoratedMethod( iname, methodName )
            if m is None:
                raise NotImplementedError

        if hasattr(m, '_dbusInterface') and m._dbusInterface != iname:
            m = self._getDecoratedMethod( iname, methodName )
            if m is None:
                raise NotImplementedError

        if not hasattr(six.get_method_function(m), '_dbusCaller'):
            self._set_method_flags(m)

        if six.get_method_function(m)._dbusCaller:
            if methodArguments:
                return m( *methodArguments, dbusCaller = sender )
            else:
                return m( dbusCaller = sender )
        else:
            if methodArguments:
                return m( *methodArguments )
            else:
                return m()
开发者ID:alexander255,项目名称:txdbus,代码行数:28,代码来源:objects.py

示例2: save_instancemethod0

def save_instancemethod0(pickler, obj):  # example: cStringIO.StringI
    log.info("Me: %s" % obj)             # XXX: obj.__dict__ handled elsewhere?

    args = (get_method_function(obj), get_method_self(obj)) if PY3 \
        else (get_method_function(obj), get_method_self(obj), obj.im_class)

    pickler.save_reduce(MethodType, args, obj=obj)

    log.info("# Me")
开发者ID:wxiang7,项目名称:dill,代码行数:9,代码来源:dill.py

示例3: __eq__

    def __eq__(self, other):
        r"""
        Return whether ``self == other``.

        EXAMPLES::

            sage: C = IntegerListsLex(2, length=3)
            sage: D = IntegerListsLex(2, length=3); L = D.list();
            sage: E = IntegerListsLex(2, min_length=3)
            sage: F = IntegerListsLex(2, length=3, element_constructor=list)
            sage: G = IntegerListsLex(4, length=3)
            sage: C == C
            True
            sage: C == D
            True
            sage: C == E
            False
            sage: C == F
            False
            sage: C == None
            False
            sage: C == G
            False

        This is a minimal implementation enabling pickling tests. It
        is safe, but one would want the two following objects to be
        detected as equal::

            sage: C = IntegerListsLex(2, ceiling=[1,1,1])
            sage: D = IntegerListsLex(2, ceiling=[1,1,1])
            sage: C == D
            False

        TESTS:

        This used to fail due to poor equality testing. See
        :trac:`17979`, comment 433::

            sage: DisjointUnionEnumeratedSets(Family([2,2],
            ....:     lambda n: IntegerListsLex(n, length=2))).list()
            [[2, 0], [1, 1], [0, 2], [2, 0], [1, 1], [0, 2]]
            sage: DisjointUnionEnumeratedSets(Family([2,2],
            ....:     lambda n: IntegerListsLex(n, length=1))).list()
            [[2], [2]]
        """
        if self.__class__ != other.__class__:
            return False
        if self.backend != other.backend:
            return False
        a = self._element_constructor_
        b = other._element_constructor_
        if ismethod(a):
            a = get_method_function(a)
        if ismethod(b):
            b = get_method_function(b)
        return a == b
开发者ID:saraedum,项目名称:sage-renamed,代码行数:56,代码来源:lists.py

示例4: __init__

    def __init__(self):
        # defiain main tasklet
        self._main_coroutine = _coroutine_getmain()

        self._main_tasklet = _coroutine_getcurrent()
        self._main_tasklet.__class__ = tasklet
        six.get_method_function(self._main_tasklet._init)(self._main_tasklet,
                label='main')
        self._last_task = self._main_tasklet

        self.thread_id = thread.get_ident()
        self._callback = None
        self._run_calls = []
        self._squeue = deque()
        self.append(self._main_tasklet)
开发者ID:RonnyPfannschmidt,项目名称:flower,代码行数:15,代码来源:sched.py

示例5: _get_es_body

    def _get_es_body(self, for_count=False):
        # If to_es has been overridden, call it and raise a deprecation warning
        if isinstance(self.query, ElasticSearchQuery) and six.get_method_function(self.query.to_es) != ElasticSearchQuery.to_es:
            warnings.warn(
                "The .to_es() method on Elasticsearch query classes is deprecated. "
                "Please rename {class_name}.to_es() to {class_name}.get_query()".format(
                    class_name=self.query.__class__.__name__
                ),
                RemovedInWagtail14Warning, stacklevel=2)

            body = {
                'query': self.query.to_es(),
            }
        else:
            body = {
                'query': self.query.get_query()
            }

        if not for_count:
            sort = self.query.get_sort()

            if sort is not None:
                body['sort'] = sort

        return body
开发者ID:nrsimha,项目名称:wagtail,代码行数:25,代码来源:elasticsearch.py

示例6: get_op_handler

    def get_op_handler(self, operation):
        """ Import and load the operation handler """
        # Patch the unversioned sdk path to include the appropriate API version for the
        # resource type in question.
        from importlib import import_module
        import types

        from azure.cli.core.profiles import AZURE_API_PROFILES
        from azure.cli.core.profiles._shared import get_versioned_sdk_path

        for rt in AZURE_API_PROFILES[self.cli_ctx.cloud.profile]:
            if operation.startswith(rt.import_prefix + ".operations."):
                subs = operation[len(rt.import_prefix + ".operations."):]
                operation_group = subs[:subs.index('_operations')]
                operation = operation.replace(
                    rt.import_prefix,
                    get_versioned_sdk_path(self.cli_ctx.cloud.profile, rt, operation_group=operation_group))
            elif operation.startswith(rt.import_prefix):
                operation = operation.replace(rt.import_prefix,
                                              get_versioned_sdk_path(self.cli_ctx.cloud.profile, rt))

        try:
            mod_to_import, attr_path = operation.split('#')
            op = import_module(mod_to_import)
            for part in attr_path.split('.'):
                op = getattr(op, part)
            if isinstance(op, types.FunctionType):
                return op
            return six.get_method_function(op)
        except (ValueError, AttributeError):
            raise ValueError("The operation '{}' is invalid.".format(operation))
开发者ID:sptramer,项目名称:azure-cli,代码行数:31,代码来源:__init__.py

示例7: __details__

 def __details__(self):
     with utils.patch(
         six.get_method_function(self.tasks.service.destroy),
         '__doc__',
         self.__doc__ + (self.tasks.service.destroy.__doc__ or ''),
     ):
         return get_task_details(self.tasks.service.destroy)
开发者ID:renskiy,项目名称:fabricio,代码行数:7,代码来源:tasks.py

示例8: test_get_method_function

def test_get_method_function():
    class X(object):
        def m(self):
            pass
    x = X()
    assert six.get_method_function(x.m) is X.__dict__["m"]
    py.test.raises(AttributeError, six.get_method_function, hasattr)
开发者ID:A-Maze,项目名称:A-Pc,代码行数:7,代码来源:test_six.py

示例9: _init_function

    def _init_function(self, r):
        if isinstance(self.function, str):
            self.function = self.function.lower()
            _mapped = {'inverse': 'inverse_multiquadric',
                       'inverse multiquadric': 'inverse_multiquadric',
                       'thin-plate': 'thin_plate'}
            if self.function in _mapped:
                self.function = _mapped[self.function]

            func_name = "_h_" + self.function
            if hasattr(self, func_name):
                self._function = getattr(self, func_name)
            else:
                functionlist = [x[3:] for x in dir(self) if x.startswith('_h_')]
                raise ValueError("function must be a callable or one of " +
                                     ", ".join(functionlist))
            self._function = getattr(self, "_h_"+self.function)
        elif callable(self.function):
            allow_one = False
            if hasattr(self.function, 'func_code') or \
                   hasattr(self.function, '__code__'):
                val = self.function
                allow_one = True
            elif hasattr(self.function, "im_func"):
                val = get_method_function(self.function)
            elif hasattr(self.function, "__call__"):
                val = get_method_function(self.function.__call__)
            else:
                raise ValueError("Cannot determine number of arguments to function")

            argcount = get_function_code(val).co_argcount
            if allow_one and argcount == 1:
                self._function = self.function
            elif argcount == 2:
                if sys.version_info[0] >= 3:
                    self._function = self.function.__get__(self, Rbf)
                else:
                    import new
                    self._function = new.instancemethod(self.function, self,
                                                        Rbf)
            else:
                raise ValueError("Function argument must take 1 or 2 arguments.")

        a0 = self._function(r)
        if a0.shape != r.shape:
            raise ValueError("Callable must take array and return array of the same shape")
        return a0
开发者ID:jsren,项目名称:sdp-vision-env,代码行数:47,代码来源:rbf.py

示例10: __init__

    def __init__(self):
        # define the main tasklet
        self._main_coroutine = _coroutine_getmain()
        self._main_tasklet = _coroutine_getcurrent()
        self._main_tasklet.__class__ = tasklet
        six.get_method_function(self._main_tasklet._init)(self._main_tasklet,
                label='main')
        self._last_task = self._main_tasklet

        self.thread_id = thread_ident() # the scheduler thread id
        self._lock = threading.Lock() # global scheduler lock

        self._callback = None # scheduler callback
        self._run_calls = [] # runcalls. (tasks where run apply
        self.runnable = deque() # runnable tasks
        self.blocked = 0 # number of blocked/sleeping tasks
        self.append(self._main_tasklet)
开发者ID:benoitc,项目名称:flower,代码行数:17,代码来源:sched.py

示例11: object_build

 def object_build(self, node, obj):
     """recursive method which create a partial ast from real objects
      (only function, class, and method are handled)
     """
     if obj in self._done:
         return self._done[obj]
     self._done[obj] = node
     for name in dir(obj):
         try:
             member = getattr(obj, name)
         except AttributeError:
             # damned ExtensionClass.Base, I know you're there !
             attach_dummy_node(node, name)
             continue
         if ismethod(member):
             member = six.get_method_function(member)
         if isfunction(member):
             # verify this is not an imported function
             filename = getattr(six.get_function_code(member),
                                'co_filename', None)
             if filename is None:
                 assert isinstance(member, object)
                 object_build_methoddescriptor(node, member, name)
             elif filename != getattr(self._module, '__file__', None):
                 attach_dummy_node(node, name, member)
             else:
                 object_build_function(node, member, name)
         elif isbuiltin(member):
             if (not _io_discrepancy(member) and
                     self.imported_member(node, member, name)):
                 continue
             object_build_methoddescriptor(node, member, name)
         elif isclass(member):
             if self.imported_member(node, member, name):
                 continue
             if member in self._done:
                 class_node = self._done[member]
                 if not class_node in node.locals.get(name, ()):
                     node.add_local_node(class_node, name)
             else:
                 class_node = object_build_class(node, member, name)
                 # recursion
                 self.object_build(class_node, member)
             if name == '__class__' and class_node.parent is None:
                 class_node.parent = self._done[self._module]
         elif ismethoddescriptor(member):
             assert isinstance(member, object)
             object_build_methoddescriptor(node, member, name)
         elif isdatadescriptor(member):
             assert isinstance(member, object)
             object_build_datadescriptor(node, member, name)
         elif type(member) in _CONSTANTS:
             attach_const_node(node, name, member)
         else:
             # create an empty node so that the name is actually defined
             attach_dummy_node(node, name, member)
开发者ID:ArthurChiao,项目名称:vim_awesome,代码行数:56,代码来源:raw_building.py

示例12: _find_method

def _find_method(obj, func):
    if obj:
        try:
            func_self = six.get_method_self(func)
        except AttributeError:  # func has no __self__
            pass
        else:
            if func_self is obj:
                return six.get_method_function(func).__name__
    raise ValueError("Function %s is not a method of: %s" % (func, obj))
开发者ID:fighting-one-piece,项目名称:repository-python,代码行数:10,代码来源:mobileonlinescheduler.py

示例13: _validate_args

    def _validate_args(self, swfuncs, tailargs):
        if six.get_method_function(self.help) in swfuncs:
            raise ShowHelp()
        if six.get_method_function(self.version) in swfuncs:
            raise ShowVersion()

        requirements = {}
        exclusions = {}
        for swinfo in self._switches_by_func.values():
            if swinfo.mandatory and not swinfo.func in swfuncs:
                raise MissingMandatorySwitch(
                    "Switch %s is mandatory" % ("/".join(("-" if len(n) == 1 else "--") + n for n in swinfo.names),)
                )
            requirements[swinfo.func] = set(self._switches_by_name[req] for req in swinfo.requires)
            exclusions[swinfo.func] = set(self._switches_by_name[exc] for exc in swinfo.excludes)

        # TODO: compute topological order

        gotten = set(swfuncs.keys())
        for func in gotten:
            missing = set(f.func for f in requirements[func]) - gotten
            if missing:
                raise SwitchCombinationError(
                    "Given %s, the following are missing %r"
                    % (swfuncs[func].swname, [self._switches_by_func[f].names[0] for f in missing])
                )
            invalid = set(f.func for f in exclusions[func]) & gotten
            if invalid:
                raise SwitchCombinationError(
                    "Given %s, the following are invalid %r"
                    % (swfuncs[func].swname, [swfuncs[f].swname for f in invalid])
                )

        m_args, m_varargs, _, m_defaults = inspect.getargspec(self.main)
        max_args = six.MAXSIZE if m_varargs else len(m_args) - 1
        min_args = len(m_args) - 1 - (len(m_defaults) if m_defaults else 0)
        if len(tailargs) < min_args:
            raise PositionalArgumentsError("Expected at least %d positional arguments, got %r" % (min_args, tailargs))
        elif len(tailargs) > max_args:
            raise PositionalArgumentsError("Expected at most %d positional arguments, got %r" % (max_args, tailargs))

        ordered = [(f, a) for _, f, a in sorted([(sf.index, f, sf.val) for f, sf in swfuncs.items()])]
        return ordered, tailargs
开发者ID:biscuit13161,项目名称:plumbum,代码行数:43,代码来源:cli.py

示例14: __str__

    def __str__(self):

        d = self.__dict__
        d['sl'] = self.sl

        try:
            fn = six.get_method_function(self.encode)
            kwargs = {k: fn(v) for k, v in d.items()}
            return self.fmt.format(**kwargs)
        except (ValueError, KeyError) as e:
            raise ValueError('Bad value in {} for {}: {}'.format(d, self.fmt, e))
开发者ID:nmb10,项目名称:geoid,代码行数:11,代码来源:__init__.py

示例15: proxified_elt

def proxified_elt(proxy):
    """Get proxified element.

    :param proxy: proxy element from where get proxified element.
    :return: proxified element. None if proxy is not proxified.
    """

    if ismethod(proxy):
        proxy = get_method_function(proxy)
    result = getattr(proxy, __PROXIFIED__, None)

    return result
开发者ID:b3j0f,项目名称:utils,代码行数:12,代码来源:proxy.py


注:本文中的six.get_method_function函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。