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


Python reflect.qual方法代码示例

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


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

示例1: name

# 需要导入模块: from twisted.python import reflect [as 别名]
# 或者: from twisted.python.reflect import qual [as 别名]
def name(thing):
    """
    @param thing: an object from modules (instance of PythonModule,
        PythonAttribute), a TestCase subclass, or an instance of a TestCase.
    """
    if isTestCase(thing):
        # TestCase subclass
        theName = reflect.qual(thing)
    else:
        # thing from trial, or thing from modules.
        # this monstrosity exists so that modules' objects do not have to
        # implement id(). -jml
        try:
            theName = thing.id()
        except AttributeError:
            theName = thing.name
    return theName 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:19,代码来源:runner.py

示例2: addError

# 需要导入模块: from twisted.python import reflect [as 别名]
# 或者: from twisted.python.reflect import qual [as 别名]
def addError(self, test, error):
        """
        Send an error over.
        """
        super(WorkerReporter, self).addError(test, error)
        testName = test.id()
        if isinstance(testName, unicode):
            testName = testName.encode("utf-8")
        failure = self._getFailure(error)
        error = failure.getErrorMessage().encode("utf-8")
        errorClass = qual(failure.type).encode("utf-8")
        frames = [frame.encode("utf-8") for frame in self._getFrames(failure)]
        self.ampProtocol.callRemote(managercommands.AddError,
                                    testName=testName,
                                    error=error,
                                    errorClass=errorClass,
                                    frames=frames) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:19,代码来源:workerreporter.py

示例3: addFailure

# 需要导入模块: from twisted.python import reflect [as 别名]
# 或者: from twisted.python.reflect import qual [as 别名]
def addFailure(self, test, fail):
        """
        Send a Failure over.
        """
        super(WorkerReporter, self).addFailure(test, fail)
        testName = test.id()
        if isinstance(testName, unicode):
            testName = testName.encode("utf-8")
        failure = self._getFailure(fail)
        fail = failure.getErrorMessage().encode("utf-8")
        failClass = qual(failure.type).encode("utf-8")
        frames = [frame.encode("utf-8") for frame in self._getFrames(failure)]
        self.ampProtocol.callRemote(managercommands.AddFailure,
                                    testName=testName,
                                    fail=fail,
                                    failClass=failClass,
                                    frames=frames) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:19,代码来源:workerreporter.py

示例4: test_reporterDeprecations

# 需要导入模块: from twisted.python import reflect [as 别名]
# 或者: from twisted.python.reflect import qual [as 别名]
def test_reporterDeprecations(self):
        """
        The runner emits a warning if it is using a result that doesn't
        implement 'done'.
        """
        trialRunner = runner.TrialRunner(None)
        result = self.FakeReporter()
        trialRunner._makeResult = lambda: result
        def f():
            # We have to use a pyunit test, otherwise we'll get deprecation
            # warnings about using iterate() in a test.
            trialRunner.run(pyunit.TestCase('id'))

        f()
        warnings = self.flushWarnings([self.test_reporterDeprecations])

        self.assertEqual(warnings[0]['category'], DeprecationWarning)
        self.assertEqual(warnings[0]['message'],
            "%s should implement done() but doesn't. Falling back to "
            "printErrors() and friends." % reflect.qual(result.__class__))
        self.assertTrue(__file__.startswith(warnings[0]['filename']))
        self.assertEqual(len(warnings), 1) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:24,代码来源:test_runner.py

示例5: spewer

# 需要导入模块: from twisted.python import reflect [as 别名]
# 或者: from twisted.python.reflect import qual [as 别名]
def spewer(frame, s, ignored):
    """
    A trace function for sys.settrace that prints every function or method call.
    """
    from twisted.python import reflect
    if 'self' in frame.f_locals:
        se = frame.f_locals['self']
        if hasattr(se, '__class__'):
            k = reflect.qual(se.__class__)
        else:
            k = reflect.qual(type(se))
        print('method %s of %s at %s' % (
                frame.f_code.co_name, k, id(se)))
    else:
        print('function %s in %s, line %s' % (
                frame.f_code.co_name,
                frame.f_code.co_filename,
                frame.f_lineno)) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:20,代码来源:util.py

示例6: addComponent

# 需要导入模块: from twisted.python import reflect [as 别名]
# 或者: from twisted.python.reflect import qual [as 别名]
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:proxysh,项目名称:Safejumper-for-Desktop,代码行数:23,代码来源:components.py

示例7: requestAvatarId

# 需要导入模块: from twisted.python import reflect [as 别名]
# 或者: from twisted.python.reflect import qual [as 别名]
def requestAvatarId(self, credentials):
        """
        Part of the L{ICredentialsChecker} interface.  Called by a portal with
        some credentials to check if they'll authenticate a user.  We check the
        interfaces that the credentials provide against our list of acceptable
        checkers.  If one of them matches, we ask that checker to verify the
        credentials.  If they're valid, we call our L{_cbGoodAuthentication}
        method to continue.

        @param credentials: the credentials the L{Portal} wants us to verify
        """
        ifac = providedBy(credentials)
        for i in ifac:
            c = self.checkers.get(i)
            if c is not None:
                d = defer.maybeDeferred(c.requestAvatarId, credentials)
                return d.addCallback(self._cbGoodAuthentication,
                        credentials)
        return defer.fail(UnhandledCredentials("No checker for %s" % \
            ', '.join(map(reflect.qual, ifac)))) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:22,代码来源:checkers.py

示例8: getStateToCopy

# 需要导入模块: from twisted.python import reflect [as 别名]
# 或者: from twisted.python.reflect import qual [as 别名]
def getStateToCopy(self):
        """
        Collect state related to the exception which occurred, discarding
        state which cannot reasonably be serialized.
        """
        state = self.__dict__.copy()
        state['tb'] = None
        state['frames'] = []
        state['stack'] = []
        state['value'] = str(self.value) # Exception instance
        if isinstance(self.type, bytes):
            state['type'] = self.type
        else:
            state['type'] = reflect.qual(self.type).encode('utf-8') # Exception class
        if self.unsafeTracebacks:
            state['traceback'] = self.getTraceback()
        else:
            state['traceback'] = 'Traceback unavailable\n'
        return state 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:21,代码来源:pb.py

示例9: test_throwExceptionIntoGenerator

# 需要导入模块: from twisted.python import reflect [as 别名]
# 或者: from twisted.python.reflect import qual [as 别名]
def test_throwExceptionIntoGenerator(self):
        """
        L{pb.CopiedFailure.throwExceptionIntoGenerator} will throw a
        L{RemoteError} into the given paused generator at the point where it
        last yielded.
        """
        original = pb.CopyableFailure(AttributeError("foo"))
        copy = jelly.unjelly(jelly.jelly(original, invoker=DummyInvoker()))
        exception = []
        def generatorFunc():
            try:
                yield None
            except pb.RemoteError as exc:
                exception.append(exc)
            else:
                self.fail("RemoteError not raised")
        gen = generatorFunc()
        gen.send(None)
        self.assertRaises(StopIteration, copy.throwExceptionIntoGenerator, gen)
        self.assertEqual(len(exception), 1)
        exc = exception[0]
        self.assertEqual(exc.remoteType, qual(AttributeError).encode("ascii"))
        self.assertEqual(exc.args, ("foo",))
        self.assertEqual(exc.remoteTraceback, 'Traceback unavailable\n') 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:26,代码来源:test_pbfailure.py

示例10: _precord_model

# 需要导入模块: from twisted.python import reflect [as 别名]
# 或者: from twisted.python.reflect import qual [as 别名]
def _precord_model(klass):
    """
    Serialize a ``PRecord`` or ``PClass`` model to something
    JSON-encodable.

    :param klass: A ``PRecord`` or ``PClass`` subclass.
    :return: Tuple of (model dictionary, further classes to process).
    """
    further_classes = set()
    if issubclass(klass, PRecord):
        attr_name = "_precord_fields"
    else:
        attr_name = "_pclass_fields"
    record = {u"category": u"record",
              u"fields": {}}
    for name, field_info in getattr(klass, attr_name).items():
        record[u"fields"][name] = sorted(
            fqpn(cls) for cls in field_info.type)
        for cls in field_info.type:
            further_classes.add(cls)
    return record, further_classes 
开发者ID:ClusterHQ,项目名称:flocker,代码行数:23,代码来源:test_model_change.py

示例11: _pmap_model

# 需要导入模块: from twisted.python import reflect [as 别名]
# 或者: from twisted.python.reflect import qual [as 别名]
def _pmap_model(klass):
    """
    Serialize a ``PMap`` model to something JSON-encodable.

    :param klass: A ``PMap`` subclass.
    :return: Tuple of (model dictionary, further classes to process).
    """
    record = {
        u"category": u"map",
        u"fields": {
            u"key": sorted(
                fqpn(cls) for cls in klass._checked_key_types),
            u"value": sorted(
                fqpn(cls) for cls in klass._checked_value_types)}}
    further_classes = set()
    for cls in klass._checked_key_types + klass._checked_value_types:
        further_classes.add(cls)
    return record, further_classes 
开发者ID:ClusterHQ,项目名称:flocker,代码行数:20,代码来源:test_model_change.py

示例12: assert_catches_changes

# 需要导入模块: from twisted.python import reflect [as 别名]
# 或者: from twisted.python.reflect import qual [as 别名]
def assert_catches_changes(self, original_class, changed_class):
        """
        Assert that ``generate_model`` changes its output when the underlying
        class has changed.

        :param original_class: Class in initial state.
        :param changed_class: Class in changed state.
        """
        original_model = generate_model(original_class)
        changed_model = generate_model(changed_class)
        # Make sure result is JSON serializable:
        dumps(original_model)
        dumps(changed_model)
        self.assertEqual(
            # If not the calling test is buggy, since it's catching wrong
            # thing, a mere name change:
            (fqpn(original_class) == fqpn(changed_class),
             # Changes result in a difference:
             original_model != changed_model,
             # No changes result in same output:
             original_model == generate_model(original_class),
             changed_model == generate_model(changed_class)),
            (True, True, True, True)) 
开发者ID:ClusterHQ,项目名称:flocker,代码行数:25,代码来源:test_model_change.py

示例13: spawn

# 需要导入模块: from twisted.python import reflect [as 别名]
# 或者: from twisted.python.reflect import qual [as 别名]
def spawn(self, hereProto, thereProto, childFDs=None):
        """
        Spawn a subprocess with a connected pair of protocol objects, one in
        the current process, one in the subprocess.

        @param hereProto: a L{Protocol} instance to listen in this process.

        @param thereProto: a top-level class or function that will be imported
            and called in the spawned subprocess.

        @param childFDs: File descriptors to share with the subprocess; same
            format as L{IReactorProcess.spawnProcess}.

        @return: a L{Deferred} that fires when C{hereProto} is ready.
        """
        if not self.running:
            self.pendingSpawns.append((hereProto, thereProto))
            return
        name = qual(thereProto)
        argv = [sys.executable, '-u', '-m', __name__, name]
        self.reactor.spawnProcess(
            BridgeProtocol(self, hereProto), sys.executable,
            argv, os.environ, childFDs=childFDs
        )
        return succeed(hereProto) 
开发者ID:apple,项目名称:ccs-twistedextensions,代码行数:27,代码来源:spawnsvc.py

示例14: jellyFor

# 需要导入模块: from twisted.python import reflect [as 别名]
# 或者: from twisted.python.reflect import qual [as 别名]
def jellyFor(self, jellier):
        qual = reflect.qual(PBMind)
        if isinstance(qual, unicode):
            qual = qual.encode("utf-8")
        return qual, jellier.invoker.registerReference(self) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:7,代码来源:service.py

示例15: writeSomeData

# 需要导入模块: from twisted.python import reflect [as 别名]
# 或者: from twisted.python.reflect import qual [as 别名]
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:proxysh,项目名称:Safejumper-for-Desktop,代码行数:14,代码来源:abstract.py


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