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


Python QgsSourceSelectProviderRegistry.providerByName方法代码示例

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


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

示例1: _testRegistry

# 需要导入模块: from qgis.gui import QgsSourceSelectProviderRegistry [as 别名]
# 或者: from qgis.gui.QgsSourceSelectProviderRegistry import providerByName [as 别名]
    def _testRegistry(self, registry):

        registry.addProvider(ConcreteSourceSelectProvider())
        registry.addProvider(ConcreteSourceSelectProvider2())

        # Check order
        self.assertEqual(['MyTestProviderKey', 'MyName'], [p.name() for p in registry.providers() if p.providerKey().startswith('MyTestProviderKey')])

        registry = QgsSourceSelectProviderRegistry()
        registry.addProvider(ConcreteSourceSelectProvider())
        registry.addProvider(ConcreteSourceSelectProvider2())

        # Check order
        self.assertEqual(['MyTestProviderKey', 'MyName'], [p.name() for p in registry.providers() if p.providerKey().startswith('MyTestProviderKey')])

        # Get provider by name
        self.assertTrue(registry.providerByName('MyTestProviderKey'))
        self.assertTrue(registry.providerByName('MyName'))

        # Get not existent by name
        self.assertFalse(registry.providerByName('Oh This Is Missing!'))

        # Get providers by data provider key
        self.assertGreater(len(registry.providersByKey('MyTestProviderKey')), 0)
        self.assertGreater(len(registry.providersByKey('MyTestProviderKey2')), 0)

        # Get not existent by key
        self.assertEqual(len(registry.providersByKey('Oh This Is Missing!')), 0)
开发者ID:Cracert,项目名称:Quantum-GIS,代码行数:30,代码来源:test_qgssourceselectprovider.py

示例2: testRemoveProvider

# 需要导入模块: from qgis.gui import QgsSourceSelectProviderRegistry [as 别名]
# 或者: from qgis.gui.QgsSourceSelectProviderRegistry import providerByName [as 别名]
    def testRemoveProvider(self):
        registry = QgsSourceSelectProviderRegistry()
        registry.addProvider(ConcreteSourceSelectProvider())
        registry.addProvider(ConcreteSourceSelectProvider2())
        self.assertEqual(['MyTestProviderKey', 'MyName'], [p.name() for p in registry.providers() if p.providerKey().startswith('MyTestProviderKey')])

        self.assertTrue(registry.removeProvider(registry.providerByName('MyName')))
        self.assertEqual(['MyTestProviderKey'], [p.name() for p in registry.providers() if p.providerKey().startswith('MyTestProviderKey')])

        self.assertTrue(registry.removeProvider(registry.providerByName('MyTestProviderKey')))
        self.assertEqual([], [p.name() for p in registry.providers() if p.providerKey().startswith('MyTestProviderKey')])
开发者ID:Cracert,项目名称:Quantum-GIS,代码行数:13,代码来源:test_qgssourceselectprovider.py


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