Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update pmr2 wfctrl #97

Merged
merged 3 commits into from
Oct 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 12 additions & 14 deletions src/mapclient/tools/pmr/importworkflowdialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)


Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/mapclient/view/managers/options/optionsdialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
32 changes: 0 additions & 32 deletions src/mapclient/view/syntaxhighlighter.py

This file was deleted.

24 changes: 24 additions & 0 deletions src/mapclient/view/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
along with MAP Client. If not, see <http://www.gnu.org/licenses/>..
"""
import logging
import re

from functools import wraps
from PySide6 import QtCore, QtGui, QtWidgets
Expand All @@ -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
Expand Down Expand Up @@ -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)
4 changes: 0 additions & 4 deletions src/mapclient/view/workflow/workflowwidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
5 changes: 3 additions & 2 deletions src/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down