Skip to content

Commit

Permalink
Fixed black issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Axel Hörteborn committed Aug 21, 2024
1 parent 4e650d6 commit cb7052e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
14 changes: 7 additions & 7 deletions a00_qpip/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def __init__(self, iface, plugin_path=None):
self._defered_packages = []
self.settings = QgsSettings()
self.settings.beginGroup("QPIP")

if plugin_path is None:
self.plugins_path = os.path.join(
QgsApplication.qgisSettingsDirPath(), "python", "plugins"
Expand Down Expand Up @@ -74,9 +74,7 @@ def initGui(self):
def initComplete(self):
if self._defered_packages:
log(f"Initialization complete. Loading deferred packages")
dialog, run_gui = self.check_deps(
additional_plugins=self._defered_packages
)
dialog, run_gui = self.check_deps(additional_plugins=self._defered_packages)
if run_gui:
self.promt_install(dialog)
self.save_settings(dialog)
Expand All @@ -98,7 +96,9 @@ def unload(self):
os.environ["PYTHONPATH"] = os.environ["PYTHONPATH"].replace(
self.bin_path + os.pathsep, ""
)
os.environ["PATH"] = os.environ["PATH"].replace(self.bin_path + os.pathsep, "")
os.environ["PATH"] = os.environ["PATH"].replace(
self.bin_path + os.pathsep, ""
)

def patched_load_plugin(self, packageName):
"""
Expand Down Expand Up @@ -183,7 +183,7 @@ def check_deps(self, additional_plugins=[]) -> MainDialog | bool:
libs.values(), self._check_on_startup(), self._check_on_install()
)
return dialog, needs_gui

def promt_install(self, dialog: MainDialog):
"""Promts the install dialog and ask the user what to install"""
if dialog.exec_():
Expand All @@ -196,7 +196,7 @@ def promt_install(self, dialog: MainDialog):
if reqs_to_install:
log(f"Will install selected dependencies : {reqs_to_install}")
self.pip_install_reqs(reqs_to_install)

def save_settings(self, dialog):
"""Stores the settings values"""
sys.path_importer_cache.clear()
Expand Down
14 changes: 9 additions & 5 deletions tests/test_finding_req.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,36 +7,40 @@

from a00_qpip.plugin import Plugin


class initializationCompleted:
def connect(self):
pass


def popWidget():
return True


THIS_DIR = os.path.dirname(__file__)


@pytest.fixture()
def plugin(qgis_iface):
qgis_iface.initializationCompleted = initializationCompleted
qgis_iface.messageBar().popWidget = popWidget
plugin = Plugin(qgis_iface, '.')
plugin = Plugin(qgis_iface, ".")
yield plugin


def test_plugin_a(plugin: Plugin):
plugin_a = os.path.join(THIS_DIR, '..', 'test_plugins', 'plugin_a')
plugin_a = os.path.join(THIS_DIR, "..", "test_plugins", "plugin_a")
dialog, needs_gui = plugin.check_deps([plugin_a])
libs = dialog.reqs_to_install
assert len(libs) == 2
assert libs[0] == 'cowsay==4.0'
assert libs[0] == "cowsay==4.0"
assert needs_gui


def test_plugin_b(plugin: Plugin):
plugin_b = os.path.join(THIS_DIR, '..', 'test_plugins', 'plugin_b')
plugin_b = os.path.join(THIS_DIR, "..", "test_plugins", "plugin_b")
dialog, needs_gui = plugin.check_deps([plugin_b])
libs = dialog.reqs_to_install
assert len(libs) == 2
assert libs[0] == 'cowsay==5.0'
assert libs[0] == "cowsay==5.0"
assert needs_gui

0 comments on commit cb7052e

Please sign in to comment.