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

Python modules.getModule函数代码示例

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

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



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


示例16: test_lookupServerViaSRV

    def test_lookupServerViaSRV(self):
        """
        Test L{lookupServerViaSRV} with a local Bind find
        """

        # Patch config
        for zonefile, checks in (
            ("db.example.com", (("example.com", "example.com", 8443,),),),
            ("db.two.zones", (
                ("example.com", "example.com", 8443,),
                ("example.org", "example.org", 8543,),
            ),),
            ("db.empty.zone", (("example.com", "", 0,),),),
        ):
            module = getModule(__name__)
            dataPath = module.filePath.sibling("data")
            bindPath = dataPath.child(zonefile)
            self.patch(config.Scheduling.iSchedule, "DNSDebug", bindPath.path)
            utils.DebugResolver = None

            for domain, result_host, result_port in checks:
                result = (yield utils.lookupServerViaSRV(domain))
                if result is None:
                    host = ""
                    port = 0
                else:
                    host, port = result
                self.assertEqual(host, result_host)
                self.assertEqual(port, result_port)
开发者ID:eventable,项目名称:CalendarServer,代码行数:29,代码来源:test_utils.py


示例17: __init__

    def __init__(self, sqlStore, uid=None, gid=None, failIfUpgradeNeeded=False):
        """
        Initialize the service.
        """
        self.sqlStore = sqlStore
        self.uid = uid
        self.gid = gid
        self.failIfUpgradeNeeded = failIfUpgradeNeeded
        self.schemaLocation = getModule(__name__).filePath.parent().parent().sibling("sql_schema")
        self.pyLocation = getModule(__name__).filePath.parent()

        self.versionKey = None
        self.versionDescriptor = ""
        self.upgradeFilePrefix = ""
        self.upgradeFileSuffix = ""
        self.defaultKeyValue = None
开发者ID:svn2github,项目名称:calendarserver-raw,代码行数:16,代码来源:upgrade.py


示例18: test_references_index

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

        schema = schemaFromPath(getModule(__name__).filePath.parent().sibling("sql_schema").child("current.sql"))

        # Get index details
        indexed_columns = set()
        for index in schema.pseudoIndexes():
            indexed_columns.add("%s.%s" % (index.table.name, index.columns[0].name))
        # print indexed_columns

        # Look at each table
        failures = []
        for table in schema.tables:
            for column in table.columns:
                if column.references is not None:
                    id = "%s.%s" % (table.name, column.name)
                    if id not in indexed_columns:
                        failures.append(id)

        self.assertEqual(
            len(failures), 0, msg="Missing index for references columns: %s" % (", ".join(sorted(failures)))
        )
开发者ID:redtailtech,项目名称:calendarserver,代码行数:25,代码来源:test_sql_schema_files.py


示例19: main

def main(reactor):
    HOST, PORT = 'localhost', 1717
    log.startLogging(sys.stdout)
    certData = getModule(__name__).filePath.sibling('server.pem').getContent()
    certificate = ssl.PrivateCertificate.loadPEM(certData)
    factory = protocol.Factory.forProtocol(Echo)
    reactor.listenSSL(PORT, factory, certificate.options())
    return defer.Deferred()
开发者ID:wichmann,项目名称:PythonExamples,代码行数:8,代码来源:twisted_server.py


示例20: main

def main(reactor):
    certData = getModule(__name__).filePath.sibling('server.pem').getContent()
    cert = ssl.PrivateCertificate.loadPEM(certData)
    factory = protocol.Factory.forProtocol(TLSServer)
    factory.options = cert.options()
    endpoint = endpoints.TCP4ServerEndpoint(reactor, 8000)
    endpoint.listen(factory)
    return defer.Deferred()
开发者ID:wellbehavedsoftware,项目名称:wbs-graphite,代码行数:8,代码来源:starttls_server.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python monkey.MonkeyPatcher类代码示例发布时间:2022-05-27
下一篇:
Python logfile.LogFile类代码示例发布时间: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