• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python reflect.prefixedMethodNames函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: listProcedures

    def listProcedures(self):
        """
        Return a list of the names of all xmlrpc procedures.

        @since: 11.1
        """
        return reflect.prefixedMethodNames(self.__class__, "xmlrpc_")
开发者ID:ssilverek,项目名称:kodb,代码行数:7,代码来源:xmlrpc.py


示例2: ctcpQuery_CLIENTINFO

    def ctcpQuery_CLIENTINFO(self, user, channel, data):
        """A master index of what CTCP tags this client knows.

        If no arguments are provided, respond with a list of known tags.
        If an argument is provided, provide human-readable help on
        the usage of that tag.
        """

        nick = string.split(user,"!")[0]
        if not data:
            # XXX: prefixedMethodNames gets methods from my *class*,
            # but it's entirely possible that this *instance* has more
            # methods.
            names = reflect.prefixedMethodNames(self.__class__,
                                                'ctcpQuery_')

            self.ctcpMakeReply(nick, [('CLIENTINFO',
                                       string.join(names, ' '))])
        else:
            args = string.split(data)
            method = getattr(self, 'ctcpQuery_%s' % (args[0],), None)
            if not method:
                self.ctcpMakeReply(nick, [('ERRMSG',
                                           "CLIENTINFO %s :"
                                           "Unknown query '%s'"
                                           % (data, args[0]))])
                return
            doc = getattr(method, '__doc__', '')
            self.ctcpMakeReply(nick, [('CLIENTINFO', doc)])
开发者ID:lhl,项目名称:songclub,代码行数:29,代码来源:irc.py


示例3: _get_provider_names

    def _get_provider_names(self):
        """
        Find the names of all supported "providers" (eg Vagrant, Rackspace).

        :return: A ``list`` of ``str`` giving all such names.
        """
        return prefixedMethodNames(self.__class__, "_runner_")
开发者ID:uedzen,项目名称:flocker,代码行数:7,代码来源:acceptance.py


示例4: testTests

    def testTests(self):
        suite = unittest.TestSuite()
        suffixes = reflect.prefixedMethodNames(TestTests.Tests, "test")
        for suffix in suffixes:
            method = "test" + suffix
            testCase = self.Tests()

            # if one of these test cases fails, switch to TextReporter to
            # see what happened

            rep = reporter.Reporter()
            #reporter = reporter.TextReporter()
            #print "running '%s'" % method

            rep.start(1)

            result = unittest.Tester(testCase.__class__, testCase,
                                     getattr(testCase, method),
                                     lambda x: x()).run()
            rep.reportResults(testCase.__class__, getattr(self.Tests, method),
                              *result)
            # TODO: verify that case.setUp == 1 and case.tearDown == 1
            try:
                self.checkResults(rep, method)
            except unittest.FailTest:
                # with TextReporter, this will show the traceback
                print
                print "problem in method '%s'" % method
                reporter.stop()
                raise
开发者ID:fxia22,项目名称:ASM_xf,代码行数:30,代码来源:test_trial.py


示例5: __init__

 def __init__(self, textView):
     self.textView=textView
     self.rkeymap = {}
     self.history = History()
     for name in prefixedMethodNames(self.__class__, "key_"):
         keysymName = name.split("_")[-1]
         self.rkeymap[getattr(gtk.keysyms, keysymName)] = keysymName
开发者ID:0004c,项目名称:VTK,代码行数:7,代码来源:gtk2manhole.py


示例6: __init__

 def __init__(self, testClass):
     self.testClass = testClass
     self.methodNames = []
     for prefix in self.methodPrefixes:
         self.methodNames.extend([ "%s%s" % (prefix, name) for name in
                                   reflect.prefixedMethodNames(testClass, prefix)])
     # N.B.: --random will shuffle testClasses but not our methodNames[]
     self.methodNames.sort()
开发者ID:fxia22,项目名称:ASM_xf,代码行数:8,代码来源:runner.py


示例7: test_inheritedMethod

 def test_inheritedMethod(self):
     """
     L{prefixedMethodNames} returns a list included methods with the given
     prefix defined on base classes of the class passed to it.
     """
     class Child(Separate):
         pass
     self.assertEqual(["method"], prefixedMethodNames(Child, "good_"))
开发者ID:JohnDoes95,项目名称:project_parser,代码行数:8,代码来源:test_reflect.py


示例8: test_reverseKeymap

 def test_reverseKeymap(self):
     """
     Verify that a L{ConsoleInput} has a reverse mapping of the keysym names
     it needs for event handling to their corresponding keysym.
     """
     ci = ConsoleInput(None)
     for eventName in prefixedMethodNames(ConsoleInput, 'key_'):
         keysymName = eventName.split("_")[-1]
         keysymValue = getattr(gtk.keysyms, keysymName)
         self.assertEqual(ci.rkeymap[keysymValue], keysymName)
开发者ID:0004c,项目名称:VTK,代码行数:10,代码来源:test_gtk2manhole.py


示例9: _computeAllowedMethods

def _computeAllowedMethods(resource):
    """
    Compute the allowed methods on a C{Resource} based on defined render_FOO
    methods. Used when raising C{UnsupportedMethod} but C{Resource} does
    not define C{allowedMethods} attribute.
    """
    allowedMethods = []
    for name in prefixedMethodNames(resource.__class__, "render_"):
        allowedMethods.append(name)
    return allowedMethods
开发者ID:narastabbocchi,项目名称:GLBackend,代码行数:10,代码来源:utils.py


示例10: applyTo

 def applyTo(self, item):
     headers = {}
     for hdr in item.impl.getAllHeaders():
         headers.setdefault(hdr.name, []).append(hdr.value)
     matchers = reflect.prefixedMethodNames(self.__class__, 'match_')
     for m in matchers:
         tag = getattr(self, 'match_' + m)(headers)
         if tag is not None:
             self.matchedMessages += 1
             assert type(tag) is unicode, "%r was not unicode, came from %r" % (tag, m)
             return True, True, {"mailingListName": tag}
     return False, True, None
开发者ID:pombredanne,项目名称:quotient,代码行数:12,代码来源:filter.py


示例11: _computeAllowedMethods

def _computeAllowedMethods(resource):
    """
    Compute the allowed methods on a C{Resource} based on defined render_FOO
    methods. Used when raising C{UnsupportedMethod} but C{Resource} does
    not define C{allowedMethods} attribute.
    """
    allowedMethods = []
    for name in prefixedMethodNames(resource.__class__, "render_"):
        # Potentially there should be an API for encode('ascii') in this
        # situation - an API for taking a Python native string (bytes on Python
        # 2, text on Python 3) and returning a socket-compatible string type.
        allowedMethods.append(name.encode('ascii'))
    return allowedMethods
开发者ID:Lovelykira,项目名称:frameworks_try,代码行数:13,代码来源:resource.py


示例12: do_EHLO

 def do_EHLO(self, rest):
     extensions = reflect.prefixedMethodNames(self.__class__, 'ext_')
     peer = self.transport.getPeer()[1]
     self.__helo = (rest, peer)
     self.__from = None
     self.__to = []
     self.sendCode(
         250,
         '%s\n%s Hello %s, nice to meet you' % (
             '\n'.join([
                 '%s %s' % (e, ' '.join(self.extArgs.get(e, []))) for e in extensions
             ]),
             self.host, peer
         )
     )
开发者ID:fxia22,项目名称:ASM_xf,代码行数:15,代码来源:smtp.py


示例13: _get_test_methods

 def _get_test_methods(self, item):
     """
     Look for test_ methods in subclasses of NetTestCase
     """
     test_cases = []
     try:
         assert issubclass(item, NetTestCase)
         methods = reflect.prefixedMethodNames(item, self.method_prefix)
         test_methods = []
         for method in methods:
             test_methods.append(self.method_prefix + method)
         if test_methods:
             test_cases.append((item, test_methods))
     except (TypeError, AssertionError):
         pass
     return test_cases
开发者ID:browserblade,项目名称:ooni-probe,代码行数:16,代码来源:nettest.py


示例14: loadTestsAndOptions

def loadTestsAndOptions(classes, cmd_line_options):
    """
    Takes a list of test classes and returns their testcases and options.
    """
    method_prefix = 'test'
    options = None
    test_cases = []

    for klass in classes:
        tests = reflect.prefixedMethodNames(klass, method_prefix)
        if tests:
            test_cases = makeTestCases(klass, tests, method_prefix)

        test_klass = klass()
        options = test_klass._processOptions(cmd_line_options)

    return test_cases, options
开发者ID:jonmtoz,项目名称:ooni-probe,代码行数:17,代码来源:runner.py


示例15: _allowed_methods

 def _allowed_methods(self):
     """
     Compute allowable http methods to return in an Allowed-Methods header.
     This is to adhere to the HTTP standard.
     """
     allowed_methods = ['HEAD']  # we always allow head
     fq_name = self.__module__ + '.' + self.__class__.__name__
     name = '?'
     try:
         resource = self
         for n in prefixedMethodNames(resource.__class__, REST_METHOD_PREFIX):
             name = n
             allowed_methods.append(n.encode('ascii'))
     except UnicodeEncodeError:
         log.err('Resource (%s) method (%s) contains non-ascii characters' % (fq_name, name))
     except Exception as e:
         log.err('Resource (%s) error resolving method names (%s)' % (fq_name, e))
     return allowed_methods
开发者ID:ajpuglis,项目名称:txrest,代码行数:18,代码来源:__init__.py


示例16: decorator

    def decorator(test_case):
        test_method_names = [
            test_prefix + name
            for name
            in prefixedMethodNames(test_case, test_prefix)
        ]
        for test_method_name in test_method_names:
            if test_method_name not in supported_tests:
                test_method = getattr(test_case, test_method_name)
                new_message = []
                existing_message = getattr(test_method, skip_or_todo, None)
                if existing_message is not None:
                    new_message.append(existing_message)
                new_message.append('Not implemented yet')
                new_message = ' '.join(new_message)

                @wraps(test_method)
                def wrapper(*args, **kwargs):
                    return test_method(*args, **kwargs)
                setattr(wrapper, skip_or_todo, new_message)
                setattr(test_case, test_method_name, wrapper)

        return test_case
开发者ID:jongiddy,项目名称:flocker,代码行数:23,代码来源:__init__.py


示例17: listProcedures

 def listProcedures(self):
     a = set(self._methods)
     b = set(reflect.prefixedMethodNames(self.__class__, 'dumbrpc_'))
     return sorted(a | b)
开发者ID:anjensan,项目名称:twoost,代码行数:4,代码来源:httprpc.py


示例18: prefixedMethodClassDict

def prefixedMethodClassDict(clazz, prefix):
    return dict([(name, getattr(clazz, prefix + name)) for name in prefixedMethodNames(clazz, prefix)])
开发者ID:deferraz,项目名称:cyclone,代码行数:2,代码来源:sux.py


示例19: listFunctions

 def listFunctions(self):
     """
     Return a list of the names of all jsonrpc methods.
     """
     return reflect.prefixedMethodNames(self.__class__, self.prefix)
开发者ID:OspreyX,项目名称:statplay,代码行数:5,代码来源:server.py


示例20: prefixedMethodObjDict

def prefixedMethodObjDict(obj, prefix):
    return dict([(name, getattr(obj, prefix + name)) for name in prefixedMethodNames(obj.__class__, prefix)])
开发者ID:deferraz,项目名称:cyclone,代码行数:2,代码来源:sux.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python reflect.qual函数代码示例发布时间:2022-05-27
下一篇:
Python reflect.objgrep函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap