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


Python reflect.namedObject方法代码示例

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


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

示例1: _buildFailure

# 需要导入模块: from twisted.python import reflect [as 别名]
# 或者: from twisted.python.reflect import namedObject [as 别名]
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.
        """
        if _PY3:
            errorClass = errorClass.decode("utf-8")
        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:proxysh,项目名称:Safejumper-for-Desktop,代码行数:24,代码来源:worker.py

示例2: _buildFailure

# 需要导入模块: from twisted.python import reflect [as 别名]
# 或者: from twisted.python.reflect import namedObject [as 别名]
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:wistbean,项目名称:learn_python3_spider,代码行数:22,代码来源:worker.py

示例3: applyUpgrade

# 需要导入模块: from twisted.python import reflect [as 别名]
# 或者: from twisted.python.reflect import namedObject [as 别名]
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: {module}", module=module)
        yield doUpgrade(self.sqlStore) 
开发者ID:apple,项目名称:ccs-calendarserver,代码行数:19,代码来源:upgrade.py

示例4: removeComponent

# 需要导入模块: from twisted.python import reflect [as 别名]
# 或者: from twisted.python.reflect import namedObject [as 别名]
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.
        """
        if (isinstance(component, types.ClassType) or
            isinstance(component, types.TypeType)):
            warnings.warn("passing interface to removeComponent, you probably want unsetComponent", DeprecationWarning, 1)
            self.unsetComponent(component)
            return [component]
        l = []
        for k, v in self._adapterCache.items():
            if v is component:
                del self._adapterCache[k]
                l.append(reflect.namedObject(k))
        return l 
开发者ID:kenorb-contrib,项目名称:BitTorrent,代码行数:20,代码来源:components.py

示例5: nevowify

# 需要导入模块: from twisted.python import reflect [as 别名]
# 或者: from twisted.python.reflect import namedObject [as 别名]
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'):
        open(newFilename, 'w').write(s)
        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)
    clonedNode.writexml(open(newFilename, 'wb')) 
开发者ID:kenorb-contrib,项目名称:BitTorrent,代码行数:23,代码来源:nevowlore.py

示例6: removeComponent

# 需要导入模块: from twisted.python import reflect [as 别名]
# 或者: from twisted.python.reflect import namedObject [as 别名]
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 list(self._adapterCache.items()):
            if v is component:
                del self._adapterCache[k]
                l.append(reflect.namedObject(k))
        return l 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:15,代码来源:components.py

示例7: unjelly

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

示例8: _unjelly_class

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

示例9: removeComponent

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

示例10: _unjelly_class

# 需要导入模块: from twisted.python import reflect [as 别名]
# 或者: from twisted.python.reflect import namedObject [as 别名]
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:kuri65536,项目名称:python-for-android,代码行数:16,代码来源:jelly.py

示例11: _unjelly_function

# 需要导入模块: from twisted.python import reflect [as 别名]
# 或者: from twisted.python.reflect import namedObject [as 别名]
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:kuri65536,项目名称:python-for-android,代码行数:10,代码来源:jelly.py

示例12: _unjelly_class

# 需要导入模块: from twisted.python import reflect [as 别名]
# 或者: from twisted.python.reflect import namedObject [as 别名]
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:kenorb-contrib,项目名称:BitTorrent,代码行数:13,代码来源:jelly.py

示例13: _unjelly_function

# 需要导入模块: from twisted.python import reflect [as 别名]
# 或者: from twisted.python.reflect import namedObject [as 别名]
def _unjelly_function(self, rest):
        modSplit = string.split(rest[0], '.')
        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])
        return function 
开发者ID:kenorb-contrib,项目名称:BitTorrent,代码行数:10,代码来源:jelly.py

示例14: _unjelly_class

# 需要导入模块: from twisted.python import reflect [as 别名]
# 或者: from twisted.python.reflect import namedObject [as 别名]
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:kenorb-contrib,项目名称:BitTorrent,代码行数:15,代码来源:newjelly.py

示例15: _unjelly_function

# 需要导入模块: from twisted.python import reflect [as 别名]
# 或者: from twisted.python.reflect import namedObject [as 别名]
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:kenorb-contrib,项目名称:BitTorrent,代码行数:12,代码来源:newjelly.py


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