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


Python plugin.Plugin方法代码示例

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


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

示例1: check

# 需要导入模块: import plugin [as 别名]
# 或者: from plugin import Plugin [as 别名]
def check(self, plugin):
        """
        Parses plugin.require(). Plase refere plugin.Plugin-documentation
        """
        plugin_requirements = self._plugin_get_requirements(plugin.require())

        if not self._check_platform(plugin_requirements["platform"]):
            required_platform = ", ".join(plugin_requirements["platform"])
            return "Requires os {}".format(required_platform)

        if not self._check_network(plugin_requirements["network"], plugin):
            return "Requires networking"

        natives_ok = self._check_native(plugin_requirements["native"], plugin)
        if natives_ok is not True:
            return natives_ok

        return True 
开发者ID:sukeesh,项目名称:Jarvis,代码行数:20,代码来源:PluginManager.py

示例2: __init__

# 需要导入模块: import plugin [as 别名]
# 或者: from plugin import Plugin [as 别名]
def __init__(self, host, pguser):

        self.host = host
        self.pguser = pguser

        # create the test database
        os.system(f"psql -h {host} -U {pguser} {dbname} -f {sql_file}")

        pg_conn_info = f"dbname={dbname} host={host} user={pguser}"
        pcon = psycopg2.connect(pg_conn_info)
        pcur = pcon.cursor()
        pcur.execute("""
        INSERT INTO epanet.junctions (id, elevation, geom)
        VALUES (33, 30, ST_GeometryFromText('POINT(3 3)',2154));
        """)
        pcur.execute("""
        INSERT INTO epanet.junctions (id, elevation, geom)
        VALUES (44, 40, ST_GeometryFromText('POINT(4 4)',2154));
        """)
        pcon.commit()
        pcon.close()

        # Initialize project
        layer_source = f"""host='{host}' dbname='{dbname}' user='{pguser}'
        srid=2154 table="epanet"."junctions" (geom) sql="""
        j_layer = QgsVectorLayer(layer_source, "junctions", "postgres")
        assert(j_layer and j_layer.isValid() and
               j_layer.featureCount() == 4)
        assert(QgsProject.instance().addMapLayer(j_layer, False))

        root = QgsProject.instance().layerTreeRoot()
        group = root.addGroup("epanet_group")
        group.addLayer(j_layer)

        self.versioning_plugin = plugin.Plugin(iface)
        self.versioning_plugin.current_layers = [j_layer]
        self.versioning_plugin.current_group = group

        self.historize() 
开发者ID:Oslandia,项目名称:qgis-versioning,代码行数:41,代码来源:plugin_test.py

示例3: _load_plugin

# 需要导入模块: import plugin [as 别名]
# 或者: from plugin import Plugin [as 别名]
def _load_plugin(self, plugin_to_add, plugin_storage):
        def handle_aliases(plugin_to_add):
            add_plugin(
                plugin_to_add.get_name().split(' '),
                plugin_to_add,
                plugin_storage)

            for name in plugin_to_add.alias():
                add_plugin(
                    name.lower().split(' '),
                    plugin_to_add,
                    plugin_storage)

        def add_plugin(name, plugin_to_add, parent):
            if len(name) == 1:
                add_plugin_single(name[0], plugin_to_add, parent)
            else:
                add_plugin_compose(name[0], name[1:], plugin_to_add, parent)

        def add_plugin_single(name, plugin_to_add, parent):
            plugin_existing = parent.get_plugins(name)
            if plugin_existing is None:
                parent.add_plugin(name, plugin_to_add)
            else:
                if not plugin_existing.is_callable_plugin():
                    plugin_existing.change_with(plugin_to_add)
                    parent.add_plugin(name, plugin_to_add)
                else:
                    error("Duplicated plugin {}!".format(name))

        def add_plugin_compose(
                name_first,
                name_remaining,
                plugin_to_add,
                parent):
            plugin_existing = parent.get_plugins(name_first)

            if plugin_existing is None:
                plugin_existing = plugin.Plugin()
                plugin_existing._name = name_first
                plugin_existing.__doc__ = ''
                parent.add_plugin(name_first, plugin_existing)

            add_plugin(name_remaining, plugin_to_add, plugin_existing)

        return handle_aliases(plugin_to_add) 
开发者ID:sukeesh,项目名称:Jarvis,代码行数:48,代码来源:PluginManager.py


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