當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。