Skip to content

Commit

Permalink
Set application version to 0.17.0. Move to use packaging version and …
Browse files Browse the repository at this point in the history
…not version tuples.
  • Loading branch information
hsorby committed Mar 16, 2022
1 parent 4a3551f commit 32db28a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 35 deletions.
44 changes: 11 additions & 33 deletions src/mapclient/core/managers/workflowmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -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.
Expand Down Expand Up @@ -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


2 changes: 1 addition & 1 deletion src/mapclient/settings/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.17.0.rc1'
__version__ = '0.17.0'
2 changes: 1 addition & 1 deletion src/mapclient/view/workflow/workflowwidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down

0 comments on commit 32db28a

Please sign in to comment.