diff --git a/src/mapclient/tools/pmr/importworkflowdialog.py b/src/mapclient/tools/pmr/importworkflowdialog.py index f03a33be..45e9f1ea 100644 --- a/src/mapclient/tools/pmr/importworkflowdialog.py +++ b/src/mapclient/tools/pmr/importworkflowdialog.py @@ -33,22 +33,22 @@ def __init__(self, previous_location, use_external_git, parent=None): self._ui = Ui_ImportWorkflowDialog() self._ui.setupUi(self) - self._previousLocation = previous_location + self._previous_location = previous_location self._use_external_git = use_external_git - self._setupPMRWidget() - self._makeConnections() + self._setup_pmr_widget() + self._make_connections() - def _makeConnections(self): - self._ui.lineEditLocation.returnPressed.connect(self._setDestination) - self._ui.pushButtonLocation.clicked.connect(self._setDestination) + def _make_connections(self): + self._ui.lineEditLocation.returnPressed.connect(self._set_destination) + self._ui.pushButtonLocation.clicked.connect(self._set_destination) def keyPressEvent(self, event): - if event.key() == QtCore.Qt.Key_Return: + if event.key() == QtCore.Qt.Key.Key_Return: return True return QtWidgets.QDialog.keyPressEvent(self, event) - def _setupPMRWidget(self): + def _setup_pmr_widget(self): self._pmr_widget = PMRWorkflowWidget(self._use_external_git, self) self._pmr_widget.setExport(False) self._pmr_widget.setImport(False) @@ -83,12 +83,10 @@ def accept(self, *args, **kwargs): if os.path.exists(destination_dir) and workspace_url: return QtWidgets.QDialog.accept(self, *args, **kwargs) else: - QtWidgets.QMessageBox.critical(self, 'Error Caught', "Invalid Import Settings. Either the workspace url '%s' was not set" \ - " or the destination directory '%s' does not exist. " % (workspace_url, destination_dir)) + QtWidgets.QMessageBox.critical(self, 'Error Caught', f"Invalid Import Settings. Either the workspace url '{workspace_url}' was not set" + f" or the destination directory '{destination_dir}' does not exist. ") - def _setDestination(self): - workflowDir = QtWidgets.QFileDialog.getExistingDirectory(self, caption='Select Workflow Directory', dir=self._previousLocation) + def _set_destination(self): + workflowDir = QtWidgets.QFileDialog.getExistingDirectory(self, caption='Select Workflow Directory', dir=self._previous_location) if workflowDir: self._ui.lineEditLocation.setText(workflowDir) - - diff --git a/src/mapclient/view/dialogs/checkstatus/checkstatusdialog.py b/src/mapclient/view/dialogs/checkstatus/checkstatusdialog.py index cdb48dc8..a8ffc4fe 100644 --- a/src/mapclient/view/dialogs/checkstatus/checkstatusdialog.py +++ b/src/mapclient/view/dialogs/checkstatus/checkstatusdialog.py @@ -7,7 +7,7 @@ from mapclient.view.dialogs.checkstatus.ui.ui_checkstatusdialog import Ui_CheckStatusDialog from mapclient.core.checks import WizardToolChecks, VCSChecks -from mapclient.view.syntaxhighlighter import SyntaxHighlighter +from mapclient.view.utils import SyntaxHighlighter from mapclient.settings.definitions import WIZARD_TOOL_STRING, \ VIRTUAL_ENVIRONMENT_STRING, PMR_TOOL_STRING diff --git a/src/mapclient/view/managers/options/optionsdialog.py b/src/mapclient/view/managers/options/optionsdialog.py index 6746a88d..e155ea3e 100644 --- a/src/mapclient/view/managers/options/optionsdialog.py +++ b/src/mapclient/view/managers/options/optionsdialog.py @@ -10,7 +10,7 @@ from mapclient.view.managers.options.ui.ui_optionsdialog import Ui_OptionsDialog from mapclient.core.checks import WizardToolChecks, VCSChecks -from mapclient.view.syntaxhighlighter import SyntaxHighlighter +from mapclient.view.utils import SyntaxHighlighter from mapclient.settings.definitions import VIRTUAL_ENVIRONMENT_STRING, \ WIZARD_TOOL_STRING, PMR_TOOL_STRING, INTERNAL_WORKFLOWS_AVAILABLE diff --git a/src/mapclient/view/syntaxhighlighter.py b/src/mapclient/view/syntaxhighlighter.py deleted file mode 100644 index 59fa7bb2..00000000 --- a/src/mapclient/view/syntaxhighlighter.py +++ /dev/null @@ -1,32 +0,0 @@ -""" -Created on Jul 1, 2015 - -@author: hsorby -""" -import re - -from PySide6 import QtCore, QtGui - -rx_success = re.compile('Success: ') -rx_failure = re.compile('Failure: ') - - -class SyntaxHighlighter(QtGui.QSyntaxHighlighter): - - def highlightBlock(self, text): - format_success = QtGui.QTextCharFormat() - format_success.setForeground(QtCore.Qt.darkGreen) - format_failure = QtGui.QTextCharFormat() - format_failure.setForeground(QtCore.Qt.darkRed) - - it = rx_success.finditer(text) - for match in it: - span = match.span() - self.setFormat(match.pos, span[1] - span[0], format_success) - - it = rx_failure.finditer(text) - for match in it: - span = match.span() - self.setFormat(match.pos, span[1] - span[0], format_failure) - - diff --git a/src/mapclient/view/utils.py b/src/mapclient/view/utils.py index d949f3f8..90cd5b27 100644 --- a/src/mapclient/view/utils.py +++ b/src/mapclient/view/utils.py @@ -18,6 +18,7 @@ along with MAP Client. If not, see .. """ import logging +import re from functools import wraps from PySide6 import QtCore, QtGui, QtWidgets @@ -28,6 +29,10 @@ logger = logging.getLogger(__name__) +rx_success = re.compile('Success: ') +rx_failure = re.compile('Failure: ') + + def create_default_image_icon(name): """ The default image size is 512x512 @@ -106,3 +111,22 @@ def do_runtime_error(self, *a, **kw): def is_light_mode(): return QtGui.QGuiApplication.styleHints().colorScheme() == QtCore.Qt.ColorScheme.Light + + +class SyntaxHighlighter(QtGui.QSyntaxHighlighter): + + def highlightBlock(self, text): + format_success = QtGui.QTextCharFormat() + format_success.setForeground(QtCore.Qt.GlobalColor.darkGreen) + format_failure = QtGui.QTextCharFormat() + format_failure.setForeground(QtCore.Qt.GlobalColor.darkRed) + + it = rx_success.finditer(text) + for match in it: + span = match.span() + self.setFormat(match.pos, span[1] - span[0], format_success) + + it = rx_failure.finditer(text) + for match in it: + span = match.span() + self.setFormat(match.pos, span[1] - span[0], format_failure) diff --git a/src/mapclient/view/workflow/workflowwidget.py b/src/mapclient/view/workflow/workflowwidget.py index 1435c080..1bc8a642 100644 --- a/src/mapclient/view/workflow/workflowwidget.py +++ b/src/mapclient/view/workflow/workflowwidget.py @@ -447,12 +447,8 @@ def performWorkflowChecks(self, workflow_dir): def _load(self, workflow_dir): try: m = self._main_window.model().workflowManager() - # self._ui.graphicsView.reset_zoom() - # m.scene().setViewParameters(self._ui.graphicsView.getViewParameters()) m.load(workflow_dir) m.setPreviousLocation(workflow_dir) - # self._ui.graphicsView.setViewParameters(m.scene().getViewParameters()) - # self._graphicsScene.setSceneRect(self._ui.graphicsView.rect()) self._graphicsScene.updateModel() self._ui.graphicsView.setLocation(workflow_dir) self._update_ui() diff --git a/src/setup.py b/src/setup.py index 4b6b3847..136979e0 100644 --- a/src/setup.py +++ b/src/setup.py @@ -37,12 +37,13 @@ def find_version(*file_paths): 'requests', 'python-dateutil', 'dulwich', - 'pmr2.wfctrl', + 'pmr2.wfctrl >= 0.5.0', 'pmr2.client >= 0.2', 'packaging', 'filelock', 'psutil == 5.9.3', - 'PyGithub' + 'PyGithub', + 'numpy', ] extras_require = {