From 32db28a61d28d6acb792f1524cf4eaf682e4a84f Mon Sep 17 00:00:00 2001 From: hsorby Date: Wed, 16 Mar 2022 13:32:14 +1300 Subject: [PATCH] Set application version to 0.17.0. Move to use packaging version and not version tuples. --- .../core/managers/workflowmanager.py | 44 +++++-------------- src/mapclient/settings/version.py | 2 +- src/mapclient/view/workflow/workflowwidget.py | 2 +- 3 files changed, 13 insertions(+), 35 deletions(-) diff --git a/src/mapclient/core/managers/workflowmanager.py b/src/mapclient/core/managers/workflowmanager.py index 0a3d77af..c593bf09 100644 --- a/src/mapclient/core/managers/workflowmanager.py +++ b/src/mapclient/core/managers/workflowmanager.py @@ -19,9 +19,9 @@ """ import os import logging -from pkg_resources import parse_version +from packaging import version -from PySide2 import QtCore, QtGui +from PySide2 import QtCore from mapclient.settings import info from mapclient.core.workflow.workflowscene import WorkflowScene @@ -65,8 +65,6 @@ class WorkflowManager(object): def __init__(self, parent): self.name = 'WorkflowManager' self._parent = parent -# self.widget = None -# self.widgetIndex = -1 self._location = '' self._conf_filename = None self._previousLocation = None @@ -78,9 +76,7 @@ def __init__(self, parent): self._scene = WorkflowScene(self) self._steps = WorkflowSteps(self) self._filtered_steps = WorkflowStepsFilter() -# self._filtered_steps = QtGui.QSortFilterProxyModel() self._filtered_steps.setSourceModel(self._steps) -# self._filtered_steps.setFilterKeyColumn(-1) def title(self): self._title = info.APPLICATION_NAME @@ -214,9 +210,9 @@ def load(self, location): if not wf.contains('version'): raise WorkflowError('The given Workflow configuration file is not valid.') - workflow_version = versionTuple(wf.value('version')) - application_version = versionTuple(info.VERSION_STRING) - if not compatibleVersions(workflow_version, application_version): + workflow_version = version.parse(wf.value('version')) + application_version = version.parse(info.VERSION_STRING) + if not _compatible_versions(workflow_version, application_version): pass # should already have thrown an exception self._location = location @@ -263,9 +259,9 @@ def save(self): if 'version' not in wf.allKeys(): wf.setValue('version', info.VERSION_STRING) - workflow_version = versionTuple(wf.value('version')) - application_version = versionTuple(info.VERSION_STRING) - if workflow_version != application_version: + workflow_version = version.parse(wf.value('version')) + application_version = version.parse(info.VERSION_STRING) + if workflow_version < application_version: wf.setValue('version', info.VERSION_STRING) self._scene.saveState(wf) @@ -281,15 +277,12 @@ def save(self): f.write(annotation) self._scene.saveAnnotation(f) -# self._title = info.APPLICATION_NAME + ' - ' + self._location - def close(self): """ Close the current workflow """ self._location = '' self._saveStateIndex = self._currentStateIndex = 0 -# self._title = info.APPLICATION_NAME def isWorkflowOpen(self): return True # not self._location == None @@ -313,11 +306,7 @@ def readSettings(self, settings): settings.endGroup() -def versionTuple(v): - return tuple(map(int, (v.split(".")))) - - -def compatibleVersions(workflow_version, application_version): +def _compatible_versions(workflow_version, application_version): """ Method checks whether two versions are compatible or not. Raises a WorkflowError exception if the two versions are not compatible. @@ -346,22 +335,11 @@ def compatibleVersions(workflow_version, application_version): if application_version == (0, 14, 0) and workflow_version == (0, 13, 0): return True - # if not workflow_version[0:2] == application_version[0:2]: - # # compare first two elements of version (major, minor) - # raise WorkflowError( - # 'Major/Minor version number mismatch - ' - # 'workflow version: %s; application version: %s.' % - # (workflow_version, application_version) - # ) - - if not parse_version('.'.join(map(str,workflow_version))) <=\ - parse_version('.'.join(map(str,application_version))): + if not workflow_version <= application_version: raise WorkflowError( 'Workflow version is newer than MAP Client - ' 'workflow version: %s; application version: %s.' % - (workflow_version, application_version) + (workflow_version, application_version) ) return True - - diff --git a/src/mapclient/settings/version.py b/src/mapclient/settings/version.py index ec2f011c..435d64bd 100644 --- a/src/mapclient/settings/version.py +++ b/src/mapclient/settings/version.py @@ -1 +1 @@ -__version__ = '0.17.0.rc1' +__version__ = '0.17.0' diff --git a/src/mapclient/view/workflow/workflowwidget.py b/src/mapclient/view/workflow/workflowwidget.py index a864a116..dd41723f 100644 --- a/src/mapclient/view/workflow/workflowwidget.py +++ b/src/mapclient/view/workflow/workflowwidget.py @@ -94,7 +94,7 @@ def _filter_text_changed(self, text): self._ui.stepTreeView.setFilterRegExp(reg_exp) def _update_ui(self): - if hasattr(self, '_mainWindow'): + if hasattr(self, '_main_window'): try: wfm = self._main_window.model().workflowManager() self._main_window.setWindowTitle(wfm.title())