--- a/src/pyams_workflow/versions.py Tue Jan 19 10:27:09 2016 +0100
+++ b/src/pyams_workflow/versions.py Tue Jan 19 10:27:45 2016 +0100
@@ -162,7 +162,7 @@
except KeyError:
raise VersionError("Missing given version ID {0}".format(version_id))
- def get_versions(self, states=None):
+ def get_versions(self, states=None, sort=False, reverse=False):
if states:
if isinstance(states, str):
states = (states, )
@@ -171,6 +171,8 @@
if state is None:
state = '__none__'
[versions.add(self[str(version)]) for version in self.versions_by_state.get(state, ())]
+ if sort:
+ versions = sorted(versions, key=lambda x: int(x.__name__), reverse=reverse)
return versions
else:
return (v for k, v in sorted(self.items(), key=lambda x: int(x[0])))