Skip to content

Commit 34ff1d5

Browse files
committed
Add third party repos support for JSON
1 parent f3b8fd8 commit 34ff1d5

File tree

3 files changed

+25
-13
lines changed

3 files changed

+25
-13
lines changed

plugin_exporter/metadata.txt

+6-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
name=Plugin Exporter
77
qgisMinimumVersion=3.20
88
description=A QGIS plugin for exporting plugins
9-
version=0.1.1
9+
version=0.2.0
1010
author=Francis Lapointe
1111
1212

@@ -20,7 +20,11 @@ repository=https://github.com/Scriptbash/PluginExporter
2020

2121
hasProcessingProvider=no
2222
# Uncomment the following line and add your changelog:
23-
# changelog=
23+
changelog=
24+
v0.2.0
25+
- Third party repositories can now be exported and imported
26+
- Add core plugin filter
27+
- Only the active plugins filter is now enabled by default
2428

2529
# Tags are comma separated with spaces allowed
2630
tags=python, qgis, plugin, importer, exporter

plugin_exporter/plugin_exporter.py

+18-10
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ def export_plugins(self):
295295
rows = table.rowCount()
296296
cols = table.columnCount()
297297

298-
if self.dlg.chk_core_plugins.isChecked():
298+
if self.dlg.chk_ext_repos.isChecked():
299299
repos = repositories.allEnabled()
300300
else:
301301
repos = None
@@ -329,6 +329,12 @@ def export_plugins(self):
329329
self.iface.messageBar().pushSuccess("Success", "Selected plugins were exported successfully.")
330330
elif file_format == '.json':
331331
with open(output_file, 'w') as file:
332+
if repos:
333+
for key, value in repos.items():
334+
if key == 'QGIS Official Plugin Repository':
335+
pass
336+
else:
337+
plugin_list.insert(0, {'id': '-', 'name': key, 'zip_repository': value['url']})
332338
json.dump(plugin_list, file)
333339
self.iface.messageBar().pushSuccess("Success", "Selected plugins were exported successfully.")
334340
except IsADirectoryError:
@@ -394,7 +400,6 @@ def import_plugins(self):
394400
try:
395401
if plugin['id'] == '-': # It's a third party repository
396402
self.add_repository(plugin)
397-
self.iface.messageBar().pushSuccess("Success", plugin['name'] + " was added to the repositories.")
398403
else:
399404
self.pyplugin.installPlugin(plugin['id'])
400405
self.iface.messageBar().pushSuccess("Success", plugin['name'] + " was installed successfully.")
@@ -411,28 +416,31 @@ def add_repository(self, repo_info):
411416
repo_name = repo_info['name']
412417
repo_url = repo_info['zip_repository']
413418
if repo_name in repositories.all():
414-
repo_name = repo_name + "(2)"
415419
self.iface.messageBar().pushInfo("Info",
416-
"Found a repository with the same names. Please check your repository "
417-
"settings for duplicate entries, the one imported ends with (2).")
418-
# add to settings
419-
settings.setValue(repo_name + "/url", repo_url)
420-
settings.setValue(repo_name + "/authcfg", "")
421-
settings.setValue(repo_name + "/enabled", "True")
422-
self.pyplugin.reloadAndExportData()
420+
"Found a repository with the same name. Skipping repository " + repo_name +
421+
". This could prevent a plugin from being installed.")
422+
else:
423+
# Adds the repo inside the settings
424+
settings.setValue(repo_name + "/url", repo_url)
425+
settings.setValue(repo_name + "/authcfg", "")
426+
settings.setValue(repo_name + "/enabled", "True")
427+
self.pyplugin.reloadAndExportData()
428+
self.iface.messageBar().pushSuccess("Success", repo_name + " was added to the repositories.")
423429

424430
# Disables and enables widgets
425431
def toggle_widget(self):
426432
if self.dlg.rd_import.isChecked():
427433
self.dlg.file_output_export.setEnabled(False)
428434
self.dlg.combo_file_format.setEnabled(False)
435+
self.dlg.chk_ext_repos.setEnabled(False)
429436
self.dlg.chk_skip_installed.setEnabled(True)
430437
self.dlg.file_input_import.setEnabled(True)
431438
else:
432439
self.dlg.file_input_import.setEnabled(False)
433440
self.dlg.chk_skip_installed.setEnabled(False)
434441
self.dlg.file_output_export.setEnabled(True)
435442
self.dlg.combo_file_format.setEnabled(True)
443+
self.dlg.chk_ext_repos.setEnabled(True)
436444

437445
# Sets the file extension filter for the QgsFileWidget
438446
def set_filter(self):

plugin_exporter/plugin_exporter_dialog_base.ui

+1-1
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@
243243
<string>Official plugins only</string>
244244
</property>
245245
<property name="checked">
246-
<bool>true</bool>
246+
<bool>false</bool>
247247
</property>
248248
</widget>
249249
</item>

0 commit comments

Comments
 (0)