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


Python modules.getModule函数代码示例

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


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

示例1: test_dottedNames

 def test_dottedNames(self):
     """ Verify that the walkModules APIs will give us back subpackages, not just
     subpackages.  """
     self.assertEquals(
         modules.getModule('twisted.python'),
         self.findByIteration("twisted.python",
                              where=modules.getModule('twisted')))
开发者ID:andrewbird,项目名称:vodafone-mobile-connect,代码行数:7,代码来源:test_modules.py

示例2: test_determineUpgradeSequence

    def test_determineUpgradeSequence(self):

        upgrader = UpgradeDatabaseSchemaStep(None)

        upgrader.schemaLocation = getModule(__name__).filePath.sibling("fake_schema1")
        files = upgrader.scanForUpgradeFiles("fake_dialect")
        upgrades = upgrader.determineUpgradeSequence(3, 4, files, "fake_dialect")
        self.assertEqual(upgrades,
            [upgrader.schemaLocation.child("upgrades").child("fake_dialect").child("upgrade_from_3_to_4.sql")],
        )
        self.assertRaises(RuntimeError, upgrader.determineUpgradeSequence, 3, 5, files, "fake_dialect")

        upgrader.schemaLocation = getModule(__name__).filePath.sibling("fake_schema2")
        files = upgrader.scanForUpgradeFiles("fake_dialect")
        upgrades = upgrader.determineUpgradeSequence(3, 5, files, "fake_dialect")
        self.assertEqual(upgrades,
            [upgrader.schemaLocation.child("upgrades").child("fake_dialect").child("upgrade_from_3_to_5.sql")]
        )
        upgrades = upgrader.determineUpgradeSequence(4, 5, files, "fake_dialect")
        self.assertEqual(upgrades,
            [upgrader.schemaLocation.child("upgrades").child("fake_dialect").child("upgrade_from_4_to_5.sql")]
        )

        upgrader.schemaLocation = getModule(__name__).filePath.sibling("fake_schema3")
        files = upgrader.scanForUpgradeFiles("fake_dialect")
        upgrades = upgrader.determineUpgradeSequence(3, 5, files, "fake_dialect")
        self.assertEqual(upgrades,
            [
                upgrader.schemaLocation.child("upgrades").child("fake_dialect").child("upgrade_from_3_to_4.sql"),
                upgrader.schemaLocation.child("upgrades").child("fake_dialect").child("upgrade_from_4_to_5.sql"),
            ]
        )
开发者ID:anemitz,项目名称:calendarserver,代码行数:32,代码来源:test_upgrade.py

示例3: main

def main(reactor):
    log.startLogging(sys.stdout)
    certData = getModule(__name__).filePath.sibling('public.pem').getContent()
    authData = getModule(__name__).filePath.sibling('server.pem').getContent()
    authority = ssl.Certificate.loadPEM(certData)
    certificate = ssl.PrivateCertificate.loadPEM(authData)
    factory = protocol.Factory.forProtocol(echoserv.Echo)
    reactor.listenSSL(8000, factory, certificate.options(authority))
    return defer.Deferred()
开发者ID:ali-hallaji,项目名称:twisted,代码行数:9,代码来源:ssl_clientauth_server.py

示例4: _populateSchema

def _populateSchema(version=None):
    """
    Generate the global L{SchemaSyntax}.
    """

    if version is None:
        pathObj = getModule(__name__).filePath.sibling("sql_schema").child("current.sql")
    else:
        pathObj = getModule(__name__).filePath.sibling("sql_schema").child("old").child(POSTGRES_DIALECT).child("%s.sql" % (version,))
    return SchemaSyntax(schemaFromPath(pathObj))
开发者ID:svn2github,项目名称:calendarserver-raw,代码行数:10,代码来源:sql_tables.py

示例5: main

def main(reactor):
    factory = protocol.Factory.forProtocol(echoclient.EchoClient)
    certData = getModule(__name__).filePath.sibling('public.pem').getContent()
    authData = getModule(__name__).filePath.sibling('server.pem').getContent()
    clientCertificate = ssl.PrivateCertificate.loadPEM(authData)
    authority = ssl.Certificate.loadPEM(certData)
    options = ssl.optionsForClientTLS(u'example.com', authority,
                                      clientCertificate)
    endpoint = endpoints.SSL4ClientEndpoint(reactor, 'localhost', 8000,
                                            options)
    echoClient = yield endpoint.connect(factory)

    done = defer.Deferred()
    echoClient.connectionLost = lambda reason: done.callback(None)
    yield done
开发者ID:ali-hallaji,项目名称:twisted,代码行数:15,代码来源:ssl_clientauth_client.py

示例6: test_pathEntriesOnPath

 def test_pathEntriesOnPath(self):
     """
     Verify that path entries discovered via module loading are, in fact, on
     sys.path somewhere.
     """
     for n in ["os", "twisted", "twisted.python", "twisted.python.reflect"]:
         self.failUnlessIn(modules.getModule(n).pathEntry.filePath.path, sys.path)
开发者ID:wangdayoux,项目名称:OpenSignals,代码行数:7,代码来源:test_modules.py

示例7: test_twistedShowsUp

 def test_twistedShowsUp(self):
     """
     Scrounge around in the top-level module namespace and make sure that
     Twisted shows up, and that the module thusly obtained is the same as
     the module that we find when we look for it explicitly by name.
     """
     self.assertEqual(modules.getModule("twisted"), self.findByIteration("twisted"))
开发者ID:wangdayoux,项目名称:OpenSignals,代码行数:7,代码来源:test_modules.py

示例8: _addBackports

def _addBackports():
    """
    We currently require 2 backported bugfixes from a future release of Twisted,
    for IPv6 support:

        - U{IPv6 client support <http://tm.tl/5085>}

        - U{TCP endpoint cancellation <http://tm.tl/4710>}

    This function will activate those backports.  (Note it must be run before
    any of the modules in question are imported or it will raise an exception.)

    This function, L{_hasIPv6ClientSupport}, and all the associated backports
    (i.e., all of C{twext/backport}) should be removed upon upgrading our
    minimum required Twisted version.
    """
    from twext.backport import internet as bpinternet
    from twisted import internet
    internet.__path__[:] = bpinternet.__path__ + internet.__path__

    # Make sure none of the backports are loaded yet.
    backports = getModule("twext.backport.internet")
    for submod in backports.iterModules():
        subname = submod.name.split(".")[-1]
        tiname = 'twisted.internet.' + subname
        if tiname in sys.modules:
            raise RuntimeError(
                tiname + "already loaded, cannot load required backport")
开发者ID:anemitz,项目名称:calendarserver,代码行数:28,代码来源:patches.py

示例9: load_processors

    def load_processors(self, load=None, noload=None, autoload=None):
        """If method parameters are not provided, they'll be looked up from
        config:
        [plugins]
            load = List of plugins / plugin.Processors to load
            noload = List of plugins / plugin.Processors to skip automatically loading
            autoload = (Boolean) Load all plugins by default?
        """
        # Sets up twisted.python so that we can iterate modules
        __import__('ibid.plugins')

        if load is None:
            load = ibid.config.plugins.get('load', [])
        if noload is None:
            noload = ibid.config.plugins.get('noload', [])

        all_plugins = set(plugin.split('.')[0] for plugin in load)
        if autoload is None:
            autoload = ibid.config.plugins.get('autoload', True)

        if autoload:
            all_plugins |= set(plugin.name.replace('ibid.plugins.', '')
                    for plugin in getModule('ibid.plugins').iterModules())

        for plugin in all_plugins:
            load_processors = [p.split('.')[1] for p in load if p.startswith(plugin + '.')]
            noload_processors = [p.split('.')[1] for p in noload if p.startswith(plugin + '.')]
            if plugin not in noload or load_processors:
                self.load_processor(plugin, noload=noload_processors, load=load_processors, load_all=(plugin in load), noload_all=(plugin in noload))
开发者ID:ibid,项目名称:ibid,代码行数:29,代码来源:core.py

示例10: _findModule

        def _findModule(self, fullname, path=None):
            # print "_findModule called with:", fullname, path

            mod = getModule(fullname)
            if mod.filePath.path.endswith('.pyc'):
                return mod.filePath.path, mod.isPackage()
            return None
开发者ID:hybridlogic,项目名称:PyPyPyc,代码行数:7,代码来源:pycimport.py

示例11: _buildTestClasses

def _buildTestClasses(_locals):
    """
    Build the test classes that use L{NewStyleOnly}, one class per module.

    @param _locals: The global C{locals()} dict.
    """
    for x in getModule("twisted").walkModules():

        ignoredModules = [
            "twisted.test.reflect_helper",
            "twisted.internet.test.process_",
            "twisted.test.process_"
        ]

        isIgnored = [x.name.startswith(ignored) for ignored in ignoredModules]

        if True in isIgnored:
            continue


        class Test(NewStyleOnly, unittest.TestCase):
            """
            @see: L{NewStyleOnly}
            """
            module = x.name

        acceptableName = x.name.replace(".", "_")
        Test.__name__ = acceptableName
        if hasattr(Test, "__qualname__"):
            Test.__qualname__ = acceptableName
        _locals.update({acceptableName: Test})
开发者ID:alfonsjose,项目名称:international-orders-app,代码行数:31,代码来源:test_nooldstyle.py

示例12: test_current_oracle

    def test_current_oracle(self):
        """
        Make sure current-oracle-dialect.sql matches current.sql
        """

        sqlSchema = getModule(__name__).filePath.parent().sibling("sql_schema")

        currentSchema = sqlSchema.child("current.sql")
        current_version = self.versionFromSchema(currentSchema)

        currentOracleSchema = sqlSchema.child("current-oracle-dialect.sql")
        current_oracle_version = self.versionFromSchema(currentOracleSchema)

        self.assertEqual(current_version, current_oracle_version)

        schema_current = schemaFromPath(currentSchema)
        schema_oracle = schemaFromPath(currentOracleSchema)

        # Remove any not null constraints in the postgres schema for text columns as in
        # Oracle nclob or nvarchar never uses not null
        for table in schema_current.tables:
            for constraint in tuple(table.constraints):
                if constraint.type == Constraint.NOT_NULL and len(constraint.affectsColumns) == 1:
                    if constraint.affectsColumns[0].type.name in ("text", "char", "varchar"):
                        table.constraints.remove(constraint)

        mismatched = schema_current.compare(schema_oracle)
        self.assertEqual(len(mismatched), 0, msg=", ".join(mismatched))
开发者ID:eventable,项目名称:CalendarServer,代码行数:28,代码来源:test_sql_schema_files.py

示例13: module

def module(s):
	base = getModule(s)
	module = base.load()
	attrs = list(base.iterAttributes())
	names = list(map(lambda x: x.name[len(x.onObject.name)+1:], list(base.iterAttributes())))
	members = list(map(lambda x: x.load(), list(base.iterAttributes())))
	return dict(zip(names, members))
开发者ID:KGerring,项目名称:package_sanity,代码行数:7,代码来源:introspection.py

示例14: test_matchCalendarUserAddress

    def test_matchCalendarUserAddress(self):
        """
        Make sure we do an exact comparison on EmailDomain
        """

        self.patch(config.Scheduling.iSchedule, "Enabled", True)
        self.patch(config.Scheduling.iSchedule, "RemoteServers", "")

        # Only mailtos:
        result = yield ScheduleViaISchedule.matchCalendarUserAddress("http://example.com/principal/user")
        self.assertFalse(result)

        # Need to setup a fake resolver
        module = getModule(__name__)
        dataPath = module.filePath.sibling("data")
        bindPath = dataPath.child("db.example.com")
        self.patch(config.Scheduling.iSchedule, "DNSDebug", bindPath.path)
        utils.DebugResolver = None
        utils._initResolver()

        result = yield ScheduleViaISchedule.matchCalendarUserAddress("mailto:[email protected]")
        self.assertTrue(result)
        result = yield ScheduleViaISchedule.matchCalendarUserAddress("mailto:[email protected]")
        self.assertFalse(result)
        result = yield ScheduleViaISchedule.matchCalendarUserAddress("mailto:[email protected]org?subject=foobar")
        self.assertFalse(result)
        result = yield ScheduleViaISchedule.matchCalendarUserAddress("mailto:user")
        self.assertFalse(result)

        # Test when not enabled
        ScheduleViaISchedule.domainServerMap = {}
        self.patch(config.Scheduling.iSchedule, "Enabled", False)
        result = yield ScheduleViaISchedule.matchCalendarUserAddress("mailto:[email protected]")
        self.assertFalse(result)
开发者ID:nunb,项目名称:calendarserver,代码行数:34,代码来源:test_delivery.py

示例15: test_nonexistentPaths

    def test_nonexistentPaths(self):
        """
        Verify that L{modules.walkModules} ignores entries in sys.path which
        do not exist in the filesystem.
        """
        existentPath = FilePath(self.mktemp())
        os.makedirs(existentPath.child("test_package").path)
        existentPath.child("test_package").child("__init__.py").setContent("")

        nonexistentPath = FilePath(self.mktemp())
        self.failIf(nonexistentPath.exists())

        originalSearchPaths = sys.path[:]
        sys.path[:] = [existentPath.path]
        try:
            expected = [modules.getModule("test_package")]

            beforeModules = list(modules.walkModules())
            sys.path.append(nonexistentPath.path)
            afterModules = list(modules.walkModules())
        finally:
            sys.path[:] = originalSearchPaths

        self.assertEqual(beforeModules, expected)
        self.assertEqual(afterModules, expected)
开发者ID:Almad,项目名称:twisted,代码行数:25,代码来源:test_modules.py


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