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

Python _reflectpy3.qual函数代码示例

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

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



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

示例1: proxyForInterface

def proxyForInterface(iface, originalAttribute="original"):
    """
    Create a class which proxies all method calls which adhere to an interface
    to another provider of that interface.

    This function is intended for creating specialized proxies. The typical way
    to use it is by subclassing the result::

      class MySpecializedProxy(proxyForInterface(IFoo)):
          def someInterfaceMethod(self, arg):
              if arg == 3:
                  return 3
              return self.original.someInterfaceMethod(arg)

    @param iface: The Interface to which the resulting object will conform, and
        which the wrapped object must provide.

    @param originalAttribute: name of the attribute used to save the original
        object in the resulting class. Default to C{original}.
    @type originalAttribute: C{str}

    @return: A class whose constructor takes the original object as its only
        argument. Constructing the class creates the proxy.
    """

    def __init__(self, original):
        setattr(self, originalAttribute, original)

    contents = {"__init__": __init__}
    for name in iface:
        contents[name] = _ProxyDescriptor(name, originalAttribute)
    proxy = type("(Proxy for %s)" % (reflect.qual(iface),), (object,), contents)
    declarations.classImplements(proxy, iface)
    return proxy
开发者ID:samsoft00,项目名称:careervacancy,代码行数:34,代码来源:components.py


示例2: getComponent

    def getComponent(self, interface, default=None):
        """Create or retrieve an adapter for the given interface.

        If such an adapter has already been created, retrieve it from the cache
        that this instance keeps of all its adapters.  Adapters created through
        this mechanism may safely store system-specific state.

        If you want to register an adapter that will be created through
        getComponent, but you don't require (or don't want) your adapter to be
        cached and kept alive for the lifetime of this Componentized object,
        set the attribute 'temporaryAdapter' to True on your adapter class.

        If you want to automatically register an adapter for all appropriate
        interfaces (with addComponent), set the attribute 'multiComponent' to
        True on your adapter class.
        """
        k = reflect.qual(interface)
        if k in self._adapterCache:
            return self._adapterCache[k]
        else:
            adapter = interface.__adapt__(self)
            if adapter is not None and not (hasattr(adapter, "temporaryAdapter") and adapter.temporaryAdapter):
                self._adapterCache[k] = adapter
                if hasattr(adapter, "multiComponent") and adapter.multiComponent:
                    self.addComponent(adapter)
            if adapter is None:
                return default
            return adapter
开发者ID:samsoft00,项目名称:careervacancy,代码行数:28,代码来源:components.py


示例3: doRead

    def doRead(self):
        """
        Called when data is available for reading.

        Subclasses must override this method. The result will be interpreted
        in the same way as a result of doWrite().
        """
        raise NotImplementedError("%s does not implement doRead" %
                                  reflect.qual(self.__class__))
开发者ID:AmirKhooj,项目名称:VTK,代码行数:9,代码来源:abstract.py


示例4: __repr__

 def __repr__(self):
     return "<%s run=%d errors=%d failures=%d todos=%d dones=%d skips=%d>" % (
         reflect.qual(self.__class__),
         self.testsRun,
         len(self.errors),
         len(self.failures),
         len(self.expectedFailures),
         len(self.skips),
         len(self.unexpectedSuccesses),
     )
开发者ID:samsoft00,项目名称:careervacancy,代码行数:10,代码来源:reporter.py


示例5: writeSomeData

    def writeSomeData(self, data):
        """
        Write as much as possible of the given data, immediately.

        This is called to invoke the lower-level writing functionality, such
        as a socket's send() method, or a file's write(); this method
        returns an integer or an exception.  If an integer, it is the number
        of bytes written (possibly zero); if an exception, it indicates the
        connection was lost.
        """
        raise NotImplementedError("%s does not implement writeSomeData" %
                                  reflect.qual(self.__class__))
开发者ID:AmirKhooj,项目名称:VTK,代码行数:12,代码来源:abstract.py


示例6: _makeContext

    def _makeContext(self):
        ctx = self._contextFactory(self.method)
        # Disallow insecure SSLv2. Applies only for SSLv23_METHOD.
        ctx.set_options(SSL.OP_NO_SSLv2)

        if self.certificate is not None and self.privateKey is not None:
            ctx.use_certificate(self.certificate)
            ctx.use_privatekey(self.privateKey)
            for extraCert in self.extraCertChain:
                ctx.add_extra_chain_cert(extraCert)
            # Sanity check
            ctx.check_privatekey()

        verifyFlags = SSL.VERIFY_NONE
        if self.verify:
            verifyFlags = SSL.VERIFY_PEER
            if self.requireCertificate:
                verifyFlags |= SSL.VERIFY_FAIL_IF_NO_PEER_CERT
            if self.verifyOnce:
                verifyFlags |= SSL.VERIFY_CLIENT_ONCE
            if self.caCerts:
                store = ctx.get_cert_store()
                for cert in self.caCerts:
                    store.add_cert(cert)

        # It'd be nice if pyOpenSSL let us pass None here for this behavior (as
        # the underlying OpenSSL API call allows NULL to be passed).  It
        # doesn't, so we'll supply a function which does the same thing.
        def _verifyCallback(conn, cert, errno, depth, preverify_ok):
            return preverify_ok
        ctx.set_verify(verifyFlags, _verifyCallback)

        if self.verifyDepth is not None:
            ctx.set_verify_depth(self.verifyDepth)

        if self.enableSingleUseKeys:
            ctx.set_options(SSL.OP_SINGLE_DH_USE)

        if self.fixBrokenPeers:
            ctx.set_options(self._OP_ALL)

        if self.enableSessions:
            name = "%s-%d" % (reflect.qual(self.__class__), _sessionCounter())
            sessionName = md5(networkString(name)).hexdigest()

            ctx.set_session_id(sessionName)

        if not self.enableSessionTickets:
            ctx.set_options(self._OP_NO_TICKET)

        return ctx
开发者ID:AlexanderHerlan,项目名称:syncpy,代码行数:51,代码来源:_sslverify.py


示例7: check

    def check(self, *errorTypes):
        """Check if this failure's type is in a predetermined list.

        @type errorTypes: list of L{Exception} classes or
                          fully-qualified class names.
        @returns: the matching L{Exception} type, or None if no match.
        """
        for error in errorTypes:
            err = error
            if inspect.isclass(error) and issubclass(error, Exception):
                err = reflect.qual(error)
            if err in self.parents:
                return error
        return None
开发者ID:AlexanderHerlan,项目名称:syncpy,代码行数:14,代码来源:failure.py


示例8: showwarning

    def showwarning(self, message, category, filename, lineno, file=None,
                    line=None):
        """
        Twisted-enabled wrapper around L{warnings.showwarning}.

        If C{file} is C{None}, the default behaviour is to emit the warning to
        the log system, otherwise the original L{warnings.showwarning} Python
        function is called.
        """
        if file is None:
            self.msg(warning=message, category=reflect.qual(category),
                     filename=filename, lineno=lineno,
                     format="%(filename)s:%(lineno)s: %(category)s: %(warning)s")
        else:
            if sys.version_info < (2, 6):
                _oldshowwarning(message, category, filename, lineno, file)
            else:
                _oldshowwarning(message, category, filename, lineno, file, line)
开发者ID:geodrinx,项目名称:gearthview,代码行数:18,代码来源:log.py


示例9: assertDefaultTraceback

    def assertDefaultTraceback(self, captureVars=False):
        """
        Assert that L{printTraceback} produces and prints a default traceback.

        The default traceback consists of a header::

          Traceback (most recent call last):

        The body with traceback::

          File "/twisted/trial/_synctest.py", line 1180, in _run
             runWithWarningsSuppressed(suppress, method)

        And the footer::

          --- <exception caught here> ---
            File "twisted/test/test_failure.py", line 39, in getDivisionFailure
              1/0
            exceptions.ZeroDivisionError: float division

        @param captureVars: Enables L{Failure.captureVars}.
        @type captureVars: C{bool}
        """
        if captureVars:
            exampleLocalVar = 'xyzzy'

        f = getDivisionFailure(captureVars=captureVars)
        out = NativeStringIO()
        f.printTraceback(out)
        tb = out.getvalue()
        stack = ''
        for method, filename, lineno, localVars, globalVars in f.frames:
            stack += '  File "%s", line %s, in %s\n' % (filename, lineno,
                                                        method)
            stack += '    %s\n' % (linecache.getline(
                                   filename, lineno).strip(),)

        self.assertTracebackFormat(tb,
            "Traceback (most recent call last):",
            "%s\n%s%s: %s\n" % (failure.EXCEPTION_CAUGHT_HERE, stack,
            reflect.qual(f.type), reflect.safe_str(f.value)))

        if captureVars:
            self.assertEqual(None, re.search('exampleLocalVar.*xyzzy', tb))
开发者ID:AlexanderHerlan,项目名称:syncpy,代码行数:44,代码来源:test_failure.py


示例10: addComponent

    def addComponent(self, component, ignoreClass=0):
        """
        Add a component to me, for all appropriate interfaces.

        In order to determine which interfaces are appropriate, the component's
        provided interfaces will be scanned.

        If the argument 'ignoreClass' is True, then all interfaces are
        considered appropriate.

        Otherwise, an 'appropriate' interface is one for which its class has
        been registered as an adapter for my class according to the rules of
        getComponent.

        @return: the list of appropriate interfaces
        """
        for iface in declarations.providedBy(component):
            if ignoreClass or (self.locateAdapterClass(self.__class__, iface, None) == component.__class__):
                self._adapterCache[reflect.qual(iface)] = component
开发者ID:samsoft00,项目名称:careervacancy,代码行数:19,代码来源:components.py


示例11: _getLogPrefix

 def _getLogPrefix(self):
     return reflect.qual(self._factory.__class__)
开发者ID:fdChasm,项目名称:spyd,代码行数:2,代码来源:enet_server_endpoint.py


示例12: __getattr__

 def __getattr__(self, k):
     kstring='get_%s'%k
     if hasattr(self.__class__,kstring):
         return getattr(self,kstring)()
     raise AttributeError("%s instance has no accessor for: %s" % (qual(self.__class__),k))
开发者ID:AmirKhooj,项目名称:VTK,代码行数:5,代码来源:reflect.py


示例13: logPrefix

 def logPrefix(self):
     """Returns the name of my class, to prefix log entries with.
     """
     return reflect.qual(self.factory.__class__)
开发者ID:AmirKhooj,项目名称:VTK,代码行数:4,代码来源:tcp.py


示例14: getWriters

 def getWriters(self):
     raise NotImplementedError(
         reflect.qual(self.__class__) + " did not implement getWriters")
开发者ID:smira,项目名称:twisted,代码行数:3,代码来源:base.py


示例15: removeAll

 def removeAll(self):
     raise NotImplementedError(
         reflect.qual(self.__class__) + " did not implement removeAll")
开发者ID:smira,项目名称:twisted,代码行数:3,代码来源:base.py


示例16: removeWriter

 def removeWriter(self, writer):
     raise NotImplementedError(
         reflect.qual(self.__class__) + " did not implement removeWriter")
开发者ID:smira,项目名称:twisted,代码行数:3,代码来源:base.py


示例17: doIteration

 def doIteration(self, delay):
     """
     Do one iteration over the readers and writers which have been added.
     """
     raise NotImplementedError(
         reflect.qual(self.__class__) + " did not implement doIteration")
开发者ID:smira,项目名称:twisted,代码行数:6,代码来源:base.py


示例18: installWaker

 def installWaker(self):
     raise NotImplementedError(
         reflect.qual(self.__class__) + " did not implement installWaker")
开发者ID:smira,项目名称:twisted,代码行数:3,代码来源:base.py


示例19: doWrite

 def doWrite(self):
     """Raises a RuntimeError"""
     raise RuntimeError(
         "doWrite called on a %s" % reflect.qual(self.__class__))
开发者ID:smira,项目名称:twisted,代码行数:4,代码来源:base.py


示例20: setComponent

 def setComponent(self, interfaceClass, component):
     """
     Cache a provider of the given interface.
     """
     self._adapterCache[reflect.qual(interfaceClass)] = component
开发者ID:samsoft00,项目名称:careervacancy,代码行数:5,代码来源:components.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python compat.execfile函数代码示例发布时间:2022-05-27
下一篇:
Python sip.parseViaHeader函数代码示例发布时间: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