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

Python reflect.qual函数代码示例

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

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



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

示例1: startFactory

 def startFactory(self):
     # disable coredumps
     if resource:
         resource.setrlimit(resource.RLIMIT_CORE, (0,0))
     else:
         log.msg('INSECURE: unable to disable core dumps.')
     if not hasattr(self,'publicKeys'):
         self.publicKeys = self.getPublicKeys()
     for keyType, value in self.publicKeys.items():
         if isinstance(value, str):
             warnings.warn("Returning a mapping from strings to "
                     "strings from getPublicKeys()/publicKeys (in %s) "
                     "is deprecated.  Return a mapping from "
                     "strings to Key objects instead." %
                     (qual(self.__class__)),
                     DeprecationWarning, stacklevel=1)
             self.publicKeys[keyType] = keys.Key.fromString(value)
     if not hasattr(self,'privateKeys'):
         self.privateKeys = self.getPrivateKeys()
     for keyType, value in self.privateKeys.items():
         if not isinstance(value, keys.Key):
             warnings.warn("Returning a mapping from strings to "
                     "PyCrypto key objects from "
                     "getPrivateKeys()/privateKeys (in %s) "
                     "is deprecated.  Return a mapping from "
                     "strings to Key objects instead." %
                     (qual(self.__class__),),
                     DeprecationWarning, stacklevel=1)
             self.privateKeys[keyType] = keys.Key(value)
     if not self.publicKeys or not self.privateKeys:
         raise error.ConchError('no host keys, failing')
     if not hasattr(self,'primes'):
         self.primes = self.getPrimes()
开发者ID:Almad,项目名称:twisted,代码行数:33,代码来源:factory.py


示例2: startFactory

 def startFactory(self):
     """
     Check for public and private keys.
     """
     if not hasattr(self, "publicKeys"):
         self.publicKeys = self.getPublicKeys()
     for keyType, value in self.publicKeys.items():
         if isinstance(value, str):
             warnings.warn(
                 "Returning a mapping from strings to "
                 "strings from getPublicKeys()/publicKeys (in %s) "
                 "is deprecated.  Return a mapping from "
                 "strings to Key objects instead." % (qual(self.__class__)),
                 DeprecationWarning,
                 stacklevel=1,
             )
             self.publicKeys[keyType] = keys.Key.fromString(value)
     if not hasattr(self, "privateKeys"):
         self.privateKeys = self.getPrivateKeys()
     for keyType, value in self.privateKeys.items():
         if not isinstance(value, keys.Key):
             warnings.warn(
                 "Returning a mapping from strings to "
                 "PyCrypto key objects from "
                 "getPrivateKeys()/privateKeys (in %s) "
                 "is deprecated.  Return a mapping from "
                 "strings to Key objects instead." % (qual(self.__class__),),
                 DeprecationWarning,
                 stacklevel=1,
             )
             self.privateKeys[keyType] = keys.Key(value)
     if not self.publicKeys or not self.privateKeys:
         raise error.ConchError("no host keys, failing")
     if not hasattr(self, "primes"):
         self.primes = self.getPrimes()
开发者ID:Bobboya,项目名称:vizitown_plugin,代码行数:35,代码来源:factory.py


示例3: test_product

 def test_product(self):
     self.product = Product(store=self.siteStore)
     self.product.types = [
         n.decode('ascii') for n in [qual(Foo), qual(Baz)]]
     self.product.installProductOn(self.userStore)
     i = self.userStore.findUnique(Installation)
     self.assertEqual(i.types, self.product.types)
开发者ID:twisted,项目名称:mantissa,代码行数:7,代码来源:test_product.py


示例4: test_deprecatedPreservesName

 def test_deprecatedPreservesName(self):
     """
     The decorated function has the same name as the original.
     """
     version = Version('Twisted', 8, 0, 0)
     dummy = deprecated(version)(dummyCallable)
     self.assertEqual(dummyCallable.__name__, dummy.__name__)
     self.assertEqual(qual(dummyCallable), qual(dummy))
开发者ID:axray,项目名称:dataware.dreamplug,代码行数:8,代码来源:test_deprecate.py


示例5: test_createProduct

 def test_createProduct(self):
     """
     Verify that L{ProductConfiguration.createProduct} creates a
     correctly configured L{Product} and returns it.
     """
     conf = ProductConfiguration(store=self.userStore)
     product = conf.createProduct([Foo, Baz])
     self.assertEqual(product.types, [qual(Foo), qual(Baz)])
开发者ID:twisted,项目名称:mantissa,代码行数:8,代码来源:test_product.py


示例6: reconfigServiceSlaves

    def reconfigServiceSlaves(self, new_config):

        timer = metrics.Timer("BotMaster.reconfigServiceSlaves")
        timer.start()

        # arrange slaves by name
        old_by_name = dict([ (s.slavename, s)
                            for s in list(self)
                            if interfaces.IBuildSlave.providedBy(s) ])
        old_set = set(old_by_name.iterkeys())
        new_by_name = dict([ (s.slavename, s)
                            for s in new_config.slaves ])
        new_set = set(new_by_name.iterkeys())

        # calculate new slaves, by name, and removed slaves
        removed_names, added_names = util.diffSets(old_set, new_set)

        # find any slaves for which the fully qualified class name has
        # changed, and treat those as an add and remove
        for n in old_set & new_set:
            old = old_by_name[n]
            new = new_by_name[n]
            # detect changed class name
            if reflect.qual(old.__class__) != reflect.qual(new.__class__):
                removed_names.add(n)
                added_names.add(n)

        if removed_names or added_names:
            log.msg("adding %d new slaves, removing %d" %
                    (len(added_names), len(removed_names)))

            for n in removed_names:
                slave = old_by_name[n]

                del self.slaves[n]
                slave.master = None
                slave.botmaster = None

                wfd = defer.waitForDeferred(
                    defer.maybeDeferred(lambda :
                        slave.disownServiceParent()))
                yield wfd
                wfd.getResult()

            for n in added_names:
                slave = new_by_name[n]
                slave.setServiceParent(self)

                slave.botmaster = self
                slave.master = self.master
                self.slaves[n] = slave

        metrics.MetricCountEvent.log("num_slaves",
                len(self.slaves), absolute=True)

        timer.stop()
开发者ID:Callek,项目名称:buildbot,代码行数:56,代码来源:botmaster.py


示例7: _checkRoundTrip

    def _checkRoundTrip(self, obj):
        """
        Make sure that an object will properly round-trip through 'qual' and
        'namedAny'.

        Raise a L{RuntimeError} if they aren't.
        """
        tripped = reflect.namedAny(reflect.qual(obj))
        if tripped is not obj:
            raise RuntimeError("importing %r is not the same as %r" %
                               (reflect.qual(obj), obj))
开发者ID:AHecky3,项目名称:evennia,代码行数:11,代码来源:main.py


示例8: makeConfigMenu

 def makeConfigMenu(self, interface):
     """Make a menu for adding a new object to a collection."""
     l = []
     if 1:
         for realClass in coil.getImplementors(interface):
             cfgClass = coil.getConfiguratorClass(realClass)
             nm = getattr(cfgClass, 'configName', None) or reflect.qual(realClass)
             l.append(['new '+reflect.qual(realClass), 'new '+nm])
     for t in self.dispensers.getDispensers(interface):
         obj, methodName, desc = t
         l.append(['dis %d' % hash(t), desc])
     return l
开发者ID:fxia22,项目名称:ASM_xf,代码行数:12,代码来源:web.py


示例9: spewer

def spewer(frame, s, ignored):
    """A trace function for sys.settrace that prints every method call."""
    from twisted.python import reflect
    if frame.f_locals.has_key('self'):
        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)
        )
开发者ID:fxia22,项目名称:ASM_xf,代码行数:12,代码来源:util.py


示例10: reconfigServiceWithBuildbotConfig

    def reconfigServiceWithBuildbotConfig(self, new_config):

        # arrange childs by name
        old_by_name = self.namedServices
        old_set = set(old_by_name.iterkeys())
        new_config_attr = getattr(new_config, self.config_attr)
        if isinstance(new_config_attr, list):
            new_by_name = dict([(s.name, s)
                                for s in new_config_attr])
        elif isinstance(new_config_attr, dict):
            new_by_name = new_config_attr
        else:
            raise TypeError("config.%s should be a list or dictionary" % (self.config_attr))
        new_set = set(new_by_name.iterkeys())

        # calculate new childs, by name, and removed childs
        removed_names, added_names = util.diffSets(old_set, new_set)

        # find any childs for which the fully qualified class name has
        # changed, and treat those as an add and remove
        for n in old_set & new_set:
            old = old_by_name[n]
            new = new_by_name[n]
            # detect changed class name
            if reflect.qual(old.__class__) != reflect.qual(new.__class__):
                removed_names.add(n)
                added_names.add(n)

        if removed_names or added_names:
            log.msg("adding %d new %s, removing %d" %
                    (len(added_names), self.config_attr, len(removed_names)))

            for n in removed_names:
                child = old_by_name[n]

                yield child.disownServiceParent()

            for n in added_names:
                child = new_by_name[n]
                yield child.setServiceParent(self)

        # get a list of child services to reconfigure
        reconfigurable_services = [svc for svc in self]

        # sort by priority
        reconfigurable_services.sort(key=lambda svc: -svc.reconfig_priority)

        for svc in reconfigurable_services:
            if not svc.name:
                raise ValueError("%r: child %r should have a defined name attribute", self, svc)
            config_sibling = new_by_name.get(svc.name)
            yield svc.reconfigServiceWithSibling(config_sibling)
开发者ID:ahlfors,项目名称:buildbot,代码行数:52,代码来源:service.py


示例11: versionUpgrade

    def versionUpgrade(self):
        """(internal) Do a version upgrade.
        """
        bases = _aybabtu(self.__class__)
        # put the bases in order so superclasses' persistenceVersion methods
        # will be called first.
        bases.reverse()
        bases.append(self.__class__)  # don't forget me!!
        # first let's look for old-skool versioned's
        if self.__dict__.has_key("persistenceVersion"):

            # Hacky heuristic: if more than one class subclasses Versioned,
            # we'll assume that the higher version number wins for the older
            # class, so we'll consider the attribute the version of the older
            # class.  There are obviously possibly times when this will
            # eventually be an incorrect assumption, but hopefully old-school
            # persistenceVersion stuff won't make it that far into multiple
            # classes inheriting from Versioned.

            pver = self.__dict__["persistenceVersion"]
            del self.__dict__["persistenceVersion"]
            highestVersion = 0
            highestBase = None
            for base in bases:
                if not base.__dict__.has_key("persistenceVersion"):
                    continue
                if base.persistenceVersion > highestVersion:
                    highestBase = base
                    highestVersion = base.persistenceVersion
            if highestBase:
                self.__dict__["%s.persistenceVersion" % reflect.qual(highestBase)] = pver
        for base in bases:
            # ugly hack, but it's what the user expects, really
            if Versioned not in base.__bases__ and not base.__dict__.has_key("persistenceVersion"):
                continue
            currentVers = base.persistenceVersion
            pverName = "%s.persistenceVersion" % reflect.qual(base)
            persistVers = self.__dict__.get(pverName) or 0
            if persistVers:
                del self.__dict__[pverName]
            assert persistVers <= currentVers, "Sorry, can't go backwards in time."
            while persistVers < currentVers:
                persistVers = persistVers + 1
                method = base.__dict__.get("upgradeToVersion%s" % persistVers, None)
                if method:
                    log.msg(
                        "Upgrading %s (of %s @ %s) to version %s"
                        % (reflect.qual(base), reflect.qual(self.__class__), id(self), persistVers)
                    )
                    method(self)
                else:
                    log.msg("Warning: cannot upgrade %s to version %s" % (base, persistVers))
开发者ID:svpcom,项目名称:twisted-cdeferred,代码行数:52,代码来源:styles.py


示例12: spewer

def spewer(frame, s, ignored):
    """A trace function for sys.settrace that prints every function or method call."""
    from twisted.python import reflect

    if frame.f_locals.has_key("self"):
        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:RichDijk,项目名称:eXe,代码行数:13,代码来源:util.py


示例13: reconfigServiceSlaves

    def reconfigServiceSlaves(self, new_config):

        timer = metrics.Timer("BuildSlaveManager.reconfigServiceSlaves")
        timer.start()

        # first we deconfigure everything to let the slaves register again
        yield self.master.data.updates.deconfigureAllBuidslavesForMaster(self.master.masterid)

        # arrange slaves by name
        old_by_name = dict([(s.slavename, s)
                            for s in list(self)
                            if IBuildSlave.providedBy(s)])
        old_set = set(old_by_name.iterkeys())
        new_by_name = dict([(s.slavename, s)
                            for s in new_config.slaves])
        new_set = set(new_by_name.iterkeys())

        # calculate new slaves, by name, and removed slaves
        removed_names, added_names = util.diffSets(old_set, new_set)

        # find any slaves for which the fully qualified class name has
        # changed, and treat those as an add and remove
        for n in old_set & new_set:
            old = old_by_name[n]
            new = new_by_name[n]
            # detect changed class name
            if reflect.qual(old.__class__) != reflect.qual(new.__class__):
                removed_names.add(n)
                added_names.add(n)

        if removed_names or added_names:
            log.msg("adding %d new slaves, removing %d" %
                    (len(added_names), len(removed_names)))

            for n in removed_names:
                slave = old_by_name[n]

                del self.slaves[n]
                slave.master = None

                yield slave.disownServiceParent()

            for n in added_names:
                slave = new_by_name[n]
                yield slave.setServiceParent(self)
                self.slaves[n] = slave

        metrics.MetricCountEvent.log("num_slaves",
                                     len(self.slaves), absolute=True)

        timer.stop()
开发者ID:alexanderkyte,项目名称:buildbot,代码行数:51,代码来源:manager.py


示例14: _setUpStore

    def _setUpStore(self):
        """
        Set up a store, install a L{HyperbolaPublicPresence} and its
        dependencies, and create a role
        """
        self.siteStore = Store(filesdir=self.mktemp())
        Mantissa().installSite(
            self.siteStore, u"localhost", u"", generateCert=False)

        # Make it standard so there's no port number in the generated URL.
        # This kind of sucks.  I don't want people assuming SSLPorts are
        # created by Mantissa().installSite().  Oh right, I should add a better
        # API for initializing a Mantissa server. -exarkun
        site = self.siteStore.findUnique(SiteConfiguration)
        ssls = list(site.store.query(SSLPort))
        ssls[0].portNumber = 443

        self.loginSystem = self.siteStore.findUnique(LoginSystem)

        product = Product(store=self.siteStore,
                          types=[qual(HyperbolaPublicPresence)])

        acct = self.loginSystem.addAccount(
            u'user', u'localhost', u'asdf', internal=True)
        self.userStore = acct.avatars.open()

        product.installProductOn(self.userStore)

        self.publicPresence = self.userStore.findUnique(
            HyperbolaPublicPresence)

        self.role = sharing.Role(
            store=self.userStore,
            externalID=u'[email protected]', description=u'foo')
开发者ID:pombredanne,项目名称:hyperbola,代码行数:34,代码来源:util.py


示例15: spawn

    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:jrossi,项目名称:twext,代码行数:25,代码来源:spawnsvc.py


示例16: _makeContext

    def _makeContext(self):
        ctx = SSL.Context(self.method)
        ctx.set_app_data(_SSLApplicationData())

        if self.certificate is not None and self.privateKey is not None:
            ctx.use_certificate(self.certificate)
            ctx.use_privatekey(self.privateKey)
            # Sanity check
            ctx.check_privatekey()

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

        def _trackVerificationProblems(conn,cert,errno,depth,preverify_ok):
            return True
        
        ctx.set_verify(verifyFlags, _trackVerificationProblems)
        
        if self.enableSessions:
            sessionName = md5.md5("%s-%d" % (reflect.qual(self.__class__), _sessionCounter())).hexdigest()
            ctx.set_session_id(sessionName)
        
        return ctx
开发者ID:AGProjects,项目名称:python-gnutls,代码行数:28,代码来源:tc-openssl.py


示例17: jellyFor

 def jellyFor(self, jellier):
     """
     @see: L{twisted.spread.interfaces.IJellyable.jellyFor}
     """
     sxp = jellier.prepare(self)
     sxp.extend([qual(self.__class__), jellier.jelly(self.getStateFor(jellier))])
     return jellier.preserve(self, sxp)
开发者ID:RockySteveJobs,项目名称:python-for-android,代码行数:7,代码来源:jelly.py


示例18: rendered

 def rendered(req):
     self.assertIn(
         qual(ThemedSubclass),
         req.v)
     self.assertIn(
         'specified no <code>fragmentName</code> attribute.',
         req.v)
开发者ID:fusionapp,项目名称:mantissa,代码行数:7,代码来源:test_theme.py


示例19: format

    def format(self, form, write, request):
        """I display an HTML FORM according to the result of self.getFormFields.
        """
        write('<form ENCTYPE="multipart/form-data" METHOD="post" ACTION="%s">\n'
              '<table BORDER="0">\n' % (self.actionURI or request.uri))

        for field in form:
            if len(field) == 5:
                inputType, displayName, inputName, inputValue, description = field
            else:
                inputType, displayName, inputName, inputValue = field
                description = ""
            write('<tr>\n<td ALIGN="right" VALIGN="top"><B>%s</B></td>\n'
                  '<td VALIGN="%s">\n' %
                  (displayName, ((inputType == 'text') and 'top') or 'middle'))
            self.formGen[inputType](write, inputName, inputValue)
            write('\n<br />\n<font size="-1">%s</font></td>\n</tr>\n' % description)


        write('<tr><td></td><td ALIGN="left"><hr />\n')
        for submitName in self.submitNames:
            write('<INPUT TYPE="submit" NAME="submit" VALUE="%s" />\n' % submitName)
        write('</td></tr>\n</table>\n'
              '<INPUT TYPE="hidden" NAME="__formtype__" VALUE="%s" />\n'
              % (reflect.qual(self.__class__)))
        fid = self.getFormID()
        if fid:
            write('<INPUT TYPE="hidden" NAME="__formid__" VALUE="%s" />\n' % fid)
        write("</form>\n")
开发者ID:KatiaBorges,项目名称:exeLearning,代码行数:29,代码来源:widgets.py


示例20: 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 self._adapterCache.has_key(k):
            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:AnthonyNystrom,项目名称:YoGoMee,代码行数:31,代码来源:components.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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