當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。