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

Python reflect.namedObject函数代码示例

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

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



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

示例1: unjelly

    def unjelly(self, obj):
        if type(obj) is not list:
            return obj
        jelTypeBytes = obj[0]
        if not self.taster.isTypeAllowed(jelTypeBytes):
            raise InsecureJelly(jelTypeBytes)
        regClass = unjellyableRegistry.get(jelTypeBytes)
        if regClass is not None:
            method = getattr(_createBlank(regClass), "unjellyFor", regClass)
            return self._maybePostUnjelly(method(self, obj))
        regFactory = unjellyableFactoryRegistry.get(jelTypeBytes)
        if regFactory is not None:
            return self._maybePostUnjelly(regFactory(self.unjelly(obj[1])))

        jelTypeText = nativeString(jelTypeBytes)
        thunk = getattr(self, '_unjelly_%s' % jelTypeText, None)
        if thunk is not None:
            return thunk(obj[1:])
        else:
            nameSplit = jelTypeText.split('.')
            modName = '.'.join(nameSplit[:-1])
            if not self.taster.isModuleAllowed(modName):
                raise InsecureJelly(
                    "Module %s not allowed (in type %s)." % (modName, jelTypeText))
            clz = namedObject(jelTypeText)
            if not self.taster.isClassAllowed(clz):
                raise InsecureJelly("Class %s not allowed." % jelTypeText)
            return self._genericUnjelly(clz, obj[1])
开发者ID:JohnDoes95,项目名称:project_parser,代码行数:28,代码来源:jelly.py


示例2: remote_registerClasses

    def remote_registerClasses(self, *args):
        """
        Instructs my broker to register the classes specified by the
        argument(s).

        The classes will be registered for B{all} jobs, and are specified by
        their string representations::
        
            <package(s).module.class>
        
        """
        modules = []
        for stringRep in args:
            # Load the class for the string representation
            cls = reflect.namedObject(stringRep)
            # Register instances of the class, including its type and module
            pb.setUnjellyableForClass(stringRep, cls)
            if cls.__module__ not in modules:
                modules.append(cls.__module__)
        # Try to build the modules for the classes in case they've changed
        # since the last run
        for module in modules:
            try:
                rebuild(reflect.namedModule(module), doLog=False)
            except:
                pass
开发者ID:D3f0,项目名称:txscada,代码行数:26,代码来源:jobs.py


示例3: autocrud

def autocrud(nodes, name, modelFQN):

    model = reflect.namedObject(modelFQN)

    schema = [a for a in dir(model) if isinstance(getattr(model, a), PropertyColumn)]

    if "id" not in schema:
        print "Sorry, this code isn't clever enough to auto-crud models with no id"
        return

    listCols = ["id"]
    if "name" in schema:
        listCols.append("name")

    crudCols = schema[:]
    crudCols.remove("id")

    if "name" in crudCols:
        crudCols.remove("name")
        crudCols.insert(0, "name")

    listColumns = ", ".join('"%s"' % c for c in listCols)
    crudColumns = textwrap.fill(", ".join('"%s"' % c for c in crudCols))

    nodeContent = crudTemplate % {
        "listColumns": listColumns,
        "crudColumns": crudColumns,
        "model": modelFQN.rsplit(".", 1)[1],
        "node": name,
    }

    skeleton.createNode(nodes, name, createIndex=False, nodeContent=nodeContent)
开发者ID:brendonh,项目名称:warp,代码行数:32,代码来源:autocrud.py


示例4: nevowify

def nevowify(filename, linkrel, ext, url, templ, options=None, outfileGenerator=tree.getOutputFileName):
    if options is None:
        options = {}
    pclass = options['pageclass']
    pclass = reflect.namedObject(pclass)
    page = pclass(docFactory=loaders.htmlfile(filename))
    s = page.renderString()
    s = ____wait(s)

    newFilename = outfileGenerator(filename, ext)

    if options.has_key('nolore'):
        f = open(newFilename, 'w')
        f.write(s)
        f.close()
        return

    doc = parseStringAndReport(s)
    clonedNode = templ.cloneNode(1)
    tree.munge(doc, clonedNode, linkrel, os.path.dirname(filename), filename, ext,
               url, options, outfileGenerator)
    tree.makeSureDirectoryExists(newFilename)
    f = open(newFilename, 'wb')
    clonedNode.writexml(f)
    f.close()
开发者ID:AnthonyNystrom,项目名称:YoGoMee,代码行数:25,代码来源:nevowlore.py


示例5: __init__

 def __init__(self, methodName):
     if type(methodName) is types.StringType:
         self.testClass = reflect.namedObject('.'.join(methodName.split('.')[:-1]))
         methodName = methodName.split('.')[-1]
     else:
         self.testClass = methodName.im_class
         self.methodName = methodName.__name__
开发者ID:fxia22,项目名称:ASM_xf,代码行数:7,代码来源:runner.py


示例6: receiveChild

 def receiveChild(self, obj, ready_deferred=None):
     assert not isinstance(obj, Deferred)
     assert ready_deferred is None
     if self.finished:
         raise BananaError("ClassUnslicer only accepts one string")
     self.finished = True
     # TODO: taste here!
     self.klass = reflect.namedObject(obj)
开发者ID:KatiaBorges,项目名称:exeLearning,代码行数:8,代码来源:slicer.py


示例7: _unjelly_function

 def _unjelly_function(self, rest):
     modSplit = rest[0].split('.')
     modName = '.'.join(modSplit[:-1])
     if not self.taster.isModuleAllowed(modName):
         raise InsecureJelly("Module not allowed: %s"% modName)
     # XXX do I need an isFunctionAllowed?
     function = namedObject(rest[0])
     return function
开发者ID:AmirKhooj,项目名称:VTK,代码行数:8,代码来源:jelly.py


示例8: _unjelly_function

 def _unjelly_function(self, rest):
     modSplit = string.split(rest[0], '.')
     # if len(rest) > 0: warn("reference numbers will be out of sync")
     modName = string.join(modSplit[:-1], '.')
     if not self.taster.isModuleAllowed(modName):
         raise InsecureJelly("Module not allowed: %s"% modName)
     # XXX do I need an isFunctionAllowed?
     function = namedObject(rest[0])
     self.resolveReference(function)
     return function
开发者ID:galaxysd,项目名称:BitTorrent,代码行数:10,代码来源:newjelly.py


示例9: _unjelly_class

 def _unjelly_class(self, rest):
     clist = string.split(rest[0], '.')
     modName = string.join(clist[:-1], '.')
     if not self.taster.isModuleAllowed(modName):
         raise InsecureJelly("module %s not allowed" % modName)
     klaus = namedObject(rest[0])
     if type(klaus) is not types.ClassType:
         raise InsecureJelly("class %s unjellied to something that isn't a class: %s" % (repr(name), repr(klaus)))
     if not self.taster.isClassAllowed(klaus):
         raise InsecureJelly("class not allowed: %s" % qual(klaus))
     return klaus
开发者ID:fxia22,项目名称:ASM_xf,代码行数:11,代码来源:jelly.py


示例10: _unjelly_class

 def _unjelly_class(self, rest):
     clist = rest[0].split(".")
     modName = ".".join(clist[:-1])
     if not self.taster.isModuleAllowed(modName):
         raise InsecureJelly("module %s not allowed" % modName)
     klaus = namedObject(rest[0])
     objType = type(klaus)
     if objType not in (types.ClassType, types.TypeType):
         raise InsecureJelly("class %r unjellied to something that isn't a class: %r" % (rest[0], klaus))
     if not self.taster.isClassAllowed(klaus):
         raise InsecureJelly("class not allowed: %s" % qual(klaus))
     return klaus
开发者ID:RockySteveJobs,项目名称:python-for-android,代码行数:12,代码来源:jelly.py


示例11: removeComponent

    def removeComponent(self, component):
        """
        Remove the given component from me entirely, for all interfaces for which
        it has been registered.

        @return: a list of the interfaces that were removed.
        """
        l = []
        for k, v in self._adapterCache.items():
            if v is component:
                del self._adapterCache[k]
                l.append(reflect.namedObject(k))
        return l
开发者ID:AnthonyNystrom,项目名称:YoGoMee,代码行数:13,代码来源:components.py


示例12: _unjelly_class

 def _unjelly_class(self, rest):
     clist = string.split(rest[0], '.')
     # if len(rest) > 0: warn("reference numbers will be out of sync")
     modName = string.join(clist[:-1], '.')
     if not self.taster.isModuleAllowed(modName):
         raise InsecureJelly("module %s not allowed" % modName)
     klaus = namedObject(rest[0])
     if type(klaus) is not types.ClassType:
         raise InsecureJelly("class %s unjellied to something that isn't a class: %s" % (repr(name), repr(klaus)))
     if not self.taster.isClassAllowed(klaus):
         raise InsecureJelly("class not allowed: %s" % qual(klaus))
     self.resolveReference(klaus)
     return klaus
开发者ID:galaxysd,项目名称:BitTorrent,代码行数:13,代码来源:newjelly.py


示例13: unjelly

 def unjelly(self, obj):
     if type(obj) is not types.ListType:
         return obj
     jelType = obj[0]
     if not self.taster.isTypeAllowed(jelType):
         raise InsecureJelly(jelType)
     regClass = unjellyableRegistry.get(jelType)
     if regClass is not None:
         if isinstance(regClass, ClassType):
             inst = _Dummy() # XXX chomp, chomp
             inst.__class__ = regClass
             method = inst.unjellyFor
         elif isinstance(regClass, type):
             # regClass.__new__ does not call regClass.__init__
             inst = regClass.__new__(regClass)
             method = inst.unjellyFor
         else:
             method = regClass # this is how it ought to be done
         val = method(self, obj)
         if hasattr(val, 'postUnjelly'):
             self.postCallbacks.append(inst.postUnjelly)
         return val
     regFactory = unjellyableFactoryRegistry.get(jelType)
     if regFactory is not None:
         state = self.unjelly(obj[1])
         inst = regFactory(state)
         if hasattr(inst, 'postUnjelly'):
             self.postCallbacks.append(inst.postUnjelly)
         return inst
     thunk = getattr(self, '_unjelly_%s'%jelType, None)
     if thunk is not None:
         ret = thunk(obj[1:])
     else:
         nameSplit = jelType.split('.')
         modName = '.'.join(nameSplit[:-1])
         if not self.taster.isModuleAllowed(modName):
             raise InsecureJelly(
                 "Module %s not allowed (in type %s)." % (modName, jelType))
         clz = namedObject(jelType)
         if not self.taster.isClassAllowed(clz):
             raise InsecureJelly("Class %s not allowed." % jelType)
         if hasattr(clz, "__setstate__"):
             ret = _newInstance(clz)
             state = self.unjelly(obj[1])
             ret.__setstate__(state)
         else:
             state = self.unjelly(obj[1])
             ret = _newInstance(clz, state)
         if hasattr(clz, 'postUnjelly'):
             self.postCallbacks.append(ret.postUnjelly)
     return ret
开发者ID:AmirKhooj,项目名称:VTK,代码行数:51,代码来源:jelly.py


示例14: run

def run():
    config = Options()
    try:
        config.parseOptions()
    except usage.error as e:
        print("%s:  %s" % (sys.argv[0], e))
        print()
        c = getattr(config, 'subOptions', config)
        print(str(c))
        sys.exit(1)

    subconfig = config.subOptions
    subcommandFunction = reflect.namedObject(subconfig.subcommandFunction)
    sys.exit(subcommandFunction(subconfig))
开发者ID:BeiNanWoo,项目名称:buildbot,代码行数:14,代码来源:runner.py


示例15: receiveClose

    def receiveClose(self):
        # you could attempt to do some value-checking here, but there would
        # probably still be holes

        #obj = Dummy()
        klass = reflect.namedObject(self.classname)
        assert type(klass) == types.ClassType # TODO: new-style classes
        obj = instance(klass, {})

        setInstanceState(obj, self.d)

        self.protocol.setObject(self.count, obj)
        self.deferred.callback(obj)
        return obj, None
开发者ID:KatiaBorges,项目名称:exeLearning,代码行数:14,代码来源:slicer.py


示例16: _unjelly_class

 def _unjelly_class(self, rest):
     cname = nativeString(rest[0])
     clist = cname.split(nativeString('.'))
     modName = nativeString('.').join(clist[:-1])
     if not self.taster.isModuleAllowed(modName):
         raise InsecureJelly("module %s not allowed" % modName)
     klaus = namedObject(cname)
     objType = type(klaus)
     if objType not in (_OldStyleClass, type):
         raise InsecureJelly(
             "class %r unjellied to something that isn't a class: %r" % (
                 cname, klaus))
     if not self.taster.isClassAllowed(klaus):
         raise InsecureJelly("class not allowed: %s" % qual(klaus))
     return klaus
开发者ID:JohnDoes95,项目名称:project_parser,代码行数:15,代码来源:jelly.py


示例17: setup

    def setup(self):
        assert not self.impl

        # imports are done locally so that we don't try to import
        # implementation-specific modules unless they're required.
        typ = self.config.mq.get('type', 'simple')
        assert typ in self.classes # this is checked by MasterConfig
        self.impl_type = typ
        cls = namedObject(self.classes[typ])
        self.impl = cls(self.highscore, self.config)

        # set up the impl as a child service
        self.impl.setServiceParent(self)

        # copy the methods onto this object for ease of access
        self.produce = self.impl.produce
        self.consume = self.impl.consume
开发者ID:buildbot,项目名称:highscore,代码行数:17,代码来源:connector.py


示例18: applyUpgrade

    def applyUpgrade(self, fp):
        """
        Apply the data upgrade .py files to the database.
        """

        # Find the module function we need to execute
        try:
            module = getModule(__name__)
            module = ".".join(module.name.split(".")[:-1]) + ".upgrades." + fp.basename()[:-3] + ".doUpgrade"
            doUpgrade = namedObject(module)
        except ImportError:
            msg = "Failed data upgrade: %s" % (fp.basename()[:-4],)
            self.log_error(msg)
            raise RuntimeError(msg)

        self.log_warn("Applying data upgrade: %s" % (module,))
        yield doUpgrade(self.sqlStore)
开发者ID:svn2github,项目名称:calendarserver-raw,代码行数:17,代码来源:upgrade.py


示例19: setup

    def setup(self):
        assert not self.impl

        # imports are done locally so that we don't try to import
        # implementation-specific modules unless they're required.
        typ = self.master.config.mq['type']
        assert typ in self.classes  # this is checked by MasterConfig
        self.impl_type = typ
        cls = namedObject(self.classes[typ]['class'])
        self.impl = cls()

        # set up the impl as a child service
        self.impl.setServiceParent(self)

        # configure it (early)
        self.impl.reconfigServiceWithBuildbotConfig(self.master.config)

        # copy the methods onto this object for ease of access
        self.produce = self.impl.produce
        self.startConsuming = self.impl.startConsuming
开发者ID:595796726,项目名称:buildbot,代码行数:20,代码来源:connector.py


示例20: _buildFailure

    def _buildFailure(self, error, errorClass, frames):
        """
        Helper to build a C{Failure} with some traceback.

        @param error: An C{Exception} instance.

        @param error: The class name of the C{error} class.

        @param frames: A flat list of strings representing the information need
            to approximatively rebuild C{Failure} frames.

        @return: A L{Failure} instance with enough information about a test
           error.
        """
        errorType = namedObject(errorClass)
        failure = Failure(error, errorType)
        for i in range(0, len(frames), 3):
            failure.frames.append(
                (frames[i], frames[i + 1], int(frames[i + 2]), [], []))
        return failure
开发者ID:0004c,项目名称:VTK,代码行数:20,代码来源:worker.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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