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


Python reflect.namedModule方法代码示例

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


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

示例1: postOptions

# 需要导入模块: from twisted.python import reflect [as 别名]
# 或者: from twisted.python.reflect import namedModule [as 别名]
def postOptions(self):
        """
        Set up conditional defaults and check for dependencies.

        If SSL is not available but an HTTPS server was configured, raise a
        L{UsageError} indicating that this is not possible.

        If no server port was supplied, select a default appropriate for the
        other options supplied.
        """
        if self['https']:
            try:
                reflect.namedModule('OpenSSL.SSL')
            except ImportError:
                raise usage.UsageError("SSL support not installed")
        if self['port'] is None:
            if not _PY3 and self['personal']:
                path = os.path.expanduser(
                    os.path.join('~', distrib.UserDirectory.userSocketName))
                self['port'] = 'unix:' + path
            else:
                self['port'] = 'tcp:8080' 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:24,代码来源:tap.py

示例2: latestClass

# 需要导入模块: from twisted.python import reflect [as 别名]
# 或者: from twisted.python.reflect import namedModule [as 别名]
def latestClass(oldClass):
    """
    Get the latest version of a class.
    """
    module = reflect.namedModule(oldClass.__module__)
    newClass = getattr(module, oldClass.__name__)
    newBases = [latestClass(base) for base in newClass.__bases__]

    try:
        # This makes old-style stuff work
        newClass.__bases__ = tuple(newBases)
        return newClass
    except TypeError:
        if newClass.__module__ == "__builtin__":
            # __builtin__ members can't be reloaded sanely
            return newClass
        ctor = getattr(newClass, '__metaclass__', type)
        return ctor(newClass.__name__, tuple(newBases), dict(newClass.__dict__)) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:20,代码来源:rebuild.py

示例3: latestClass

# 需要导入模块: from twisted.python import reflect [as 别名]
# 或者: from twisted.python.reflect import namedModule [as 别名]
def latestClass(oldClass):
    """
    Get the latest version of a class.
    """
    module = reflect.namedModule(oldClass.__module__)
    newClass = getattr(module, oldClass.__name__)
    newBases = [latestClass(base) for base in newClass.__bases__]

    try:
        # This makes old-style stuff work
        newClass.__bases__ = tuple(newBases)
        return newClass
    except TypeError:
        if newClass.__module__ in ("__builtin__", "builtins"):
            # __builtin__ members can't be reloaded sanely
            return newClass

        ctor = type(newClass)
        # The value of type(newClass) is the metaclass
        # in both Python 2 and 3, except if it was old-style.
        if _isClassType(ctor):
            ctor = getattr(newClass, '__metaclass__', type)
        return ctor(newClass.__name__, tuple(newBases),
                    dict(newClass.__dict__)) 
开发者ID:wistbean,项目名称:learn_python3_spider,代码行数:26,代码来源:rebuild.py

示例4: getProcessor

# 需要导入模块: from twisted.python import reflect [as 别名]
# 或者: from twisted.python.reflect import namedModule [as 别名]
def getProcessor(input, output, config):
    plugins = plugin.getPlugins(IProcessor)
    for plug in plugins:
        if plug.name == input:
            module = reflect.namedModule(plug.moduleName)
            break
    else:
        # try treating it as a module name
        try:
            module = reflect.namedModule(input)
        except ImportError:
            print '%s: no such input: %s' % (sys.argv[0], input)
            return
    try:
        return process.getProcessor(module, output, config)
    except process.NoProcessorError, e:
        print "%s: %s" % (sys.argv[0], e) 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:19,代码来源:lore.py

示例5: testModules

# 需要导入模块: from twisted.python import reflect [as 别名]
# 或者: from twisted.python.reflect import namedModule [as 别名]
def testModules(self):
        """Looking for docstrings in all modules."""
        docless = []
        for packageName in self.packageNames:
            if packageName in ('twisted.test',):
                # because some stuff in here behaves oddly when imported
                continue
            try:
                package = reflect.namedModule(packageName)
            except ImportError, e:
                # This is testing doc coverage, not importability.
                # (Really, I don't want to deal with the fact that I don't
                #  have pyserial installed.)
                # print e
                pass
            else:
                docless.extend(self.modulesInPackage(packageName, package)) 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:19,代码来源:test_doc.py

示例6: modulesInPackage

# 需要导入模块: from twisted.python import reflect [as 别名]
# 或者: from twisted.python.reflect import namedModule [as 别名]
def modulesInPackage(self, packageName, package):
        docless = []
        directory = path.dirname(package.__file__)
        for modfile in glob.glob(path.join(directory, '*.py')):
            moduleName = inspect.getmodulename(modfile)
            if moduleName == '__init__':
                # These are tested by test_packages.
                continue
            elif moduleName in ('spelunk_gnome','gtkmanhole'):
                # argh special case pygtk evil argh.  How does epydoc deal
                # with this?
                continue
            try:
                module = reflect.namedModule('.'.join([packageName,
                                                       moduleName]))
            except Exception, e:
                # print moduleName, "misbehaved:", e
                pass
            else:
                if not inspect.getdoc(module):
                    docless.append(modfile) 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:23,代码来源:test_doc.py

示例7: getChild

# 需要导入模块: from twisted.python import reflect [as 别名]
# 或者: from twisted.python.reflect import namedModule [as 别名]
def getChild(self, path, request):
        if path == '':
            # ZOOP!
            if isinstance(self, Widget):
                return self.pageFactory(self)
        widget = self.getWidget(path, request)
        if widget:
            if isinstance(widget, resource.Resource):
                return widget
            else:
                p = self.pageFactory(widget)
                p.isLeaf = getattr(widget,'isLeaf',0)
                return p
        elif self.paths.has_key(path):
            prefix = getattr(sys.modules[self.__module__], '__file__', '')
            if prefix:
                prefix = os.path.abspath(os.path.dirname(prefix))
            return static.File(os.path.join(prefix, self.paths[path]))

        elif path == '__reload__':
            return self.pageFactory(Reloader(map(reflect.namedModule, [self.__module__] + self.modules)))
        else:
            return error.NoResource("No such child resource in gadget.") 
开发者ID:kenorb-contrib,项目名称:BitTorrent,代码行数:25,代码来源:widgets.py

示例8: getProcessor

# 需要导入模块: from twisted.python import reflect [as 别名]
# 或者: from twisted.python.reflect import namedModule [as 别名]
def getProcessor(input, output, config):
    plugins = oldplugin._getPlugIns("lore")
    for plug in plugins:
        if plug.tapname == input:
            module = plug.load()
            break
    else:
        plugins = newplugin.getPlugins(IProcessor)
        for plug in plugins:
            if plug.name == input:
                module = reflect.namedModule(plug.moduleName)
                break
        else:
            # try treating it as a module name
            try:
                module = reflect.namedModule(input)
            except ImportError:
                print '%s: no such input: %s' % (sys.argv[0], input)
                return
    try:
        return process.getProcessor(module, output, config)
    except process.NoProcessorError, e:
        print "%s: %s" % (sys.argv[0], e) 
开发者ID:kenorb-contrib,项目名称:BitTorrent,代码行数:25,代码来源:lore.py

示例9: test_namedModuleLookup

# 需要导入模块: from twisted.python import reflect [as 别名]
# 或者: from twisted.python.reflect import namedModule [as 别名]
def test_namedModuleLookup(self):
        """
        L{namedModule} should return the module object for the name it is
        passed.
        """
        from twisted.python import monkey
        self.assertIs(
            reflect.namedModule("twisted.python.monkey"), monkey) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:10,代码来源:test_reflect.py

示例10: postOptions

# 需要导入模块: from twisted.python import reflect [as 别名]
# 或者: from twisted.python.reflect import namedModule [as 别名]
def postOptions(self):
        """
        Set up conditional defaults and check for dependencies.

        If SSL is not available but an HTTPS server was configured, raise a
        L{UsageError} indicating that this is not possible.

        If no server port was supplied, select a default appropriate for the
        other options supplied.
        """
        if self['port'] is not None:
            self['ports'].append(self['port'])
        if self['https'] is not None:
            try:
                reflect.namedModule('OpenSSL.SSL')
            except ImportError:
                raise usage.UsageError("SSL support not installed")
            sslStrport = 'ssl:port={}:privateKey={}:certKey={}'.format(
                             self['https'],
                             self['privkey'],
                             self['certificate'],
                         )
            self['ports'].append(sslStrport)
        if len(self['ports']) == 0:
            if self['personal']:
                path = os.path.expanduser(
                    os.path.join('~', distrib.UserDirectory.userSocketName))
                self['ports'].append('unix:' + path)
            else:
                self['ports'].append('tcp:8080') 
开发者ID:wistbean,项目名称:learn_python3_spider,代码行数:32,代码来源:tap.py

示例11: test_namedModuleLookup

# 需要导入模块: from twisted.python import reflect [as 别名]
# 或者: from twisted.python.reflect import namedModule [as 别名]
def test_namedModuleLookup(self):
        """
        L{namedModule} should return the module object for the name it is
        passed.
        """
        self.assertIdentical(
            reflect.namedModule("twisted.python.reflect"), reflect) 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:9,代码来源:test_reflect.py

示例12: installReactor

# 需要导入模块: from twisted.python import reflect [as 别名]
# 或者: from twisted.python.reflect import namedModule [as 别名]
def installReactor(reactor):
    if reactor:
        reflect.namedModule(reactorTypes[reactor]).install() 
开发者ID:kenorb-contrib,项目名称:BitTorrent,代码行数:5,代码来源:app.py

示例13: moduleMovedForSplit

# 需要导入模块: from twisted.python import reflect [as 别名]
# 或者: from twisted.python.reflect import namedModule [as 别名]
def moduleMovedForSplit(origModuleName, newModuleName, moduleDesc,
                        projectName, projectURL, globDict):
    from twisted.python import reflect
    modoc = """
%(moduleDesc)s

This module is DEPRECATED. It has been split off into a third party
package, Twisted %(projectName)s. Please see %(projectURL)s.

This is just a place-holder that imports from the third-party %(projectName)s
package for backwards compatibility. To use it, you need to install
that package.
""" % {'moduleDesc': moduleDesc,
       'projectName': projectName,
       'projectURL': projectURL}

    #origModule = reflect.namedModule(origModuleName)
    try:
        newModule = reflect.namedModule(newModuleName)
    except ImportError:
        raise ImportError("You need to have the Twisted %s "
                          "package installed to use %s. "
                          "See %s."
                          % (projectName, origModuleName, projectURL))

    # Populate the old module with the new module's contents
    for k,v in vars(newModule).items():
        globDict[k] = v
    globDict['__doc__'] = modoc
    import warnings
    warnings.warn("%s has moved to %s. See %s." % (origModuleName, newModuleName,
                                                   projectURL),
                  DeprecationWarning, stacklevel=3)
    return 
开发者ID:kenorb-contrib,项目名称:BitTorrent,代码行数:36,代码来源:util.py

示例14: testModuleLookup

# 需要导入模块: from twisted.python import reflect [as 别名]
# 或者: from twisted.python.reflect import namedModule [as 别名]
def testModuleLookup(self):
        self.assertEquals(reflect.namedModule("twisted.python.reflect"), reflect) 
开发者ID:kenorb-contrib,项目名称:BitTorrent,代码行数:4,代码来源:test_reflect.py

示例15: testPackages

# 需要导入模块: from twisted.python import reflect [as 别名]
# 或者: from twisted.python.reflect import namedModule [as 别名]
def testPackages(self):
        """Looking for docstrings in all packages."""
        docless = []
        for packageName in self.packageNames:
            try:
                package = reflect.namedModule(packageName)
            except Exception, e:
                # This is testing doc coverage, not importability.
                # (Really, I don't want to deal with the fact that I don't
                #  have pyserial installed.)
                # print e
                pass
            else:
                if not inspect.getdoc(package):
                    docless.append(package.__file__.replace('.pyc','.py')) 
开发者ID:kenorb-contrib,项目名称:BitTorrent,代码行数:17,代码来源:test_doc.py


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