Skip to content

Commit

Permalink
Global config hierarchy: Separate dev from prerelease
Browse files Browse the repository at this point in the history
Plus fix a pycodestyle "error"
  • Loading branch information
MetRonnie committed Sep 2, 2020
1 parent 7b778bb commit 4545763
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions cylc/flow/cfgspec/globalcfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -705,13 +705,17 @@ def get_version_hierarchy(version):
version (str): A PEP 440 compliant version number.
Example:
>>> get_version_hierarchy('8.0.1a2')
['', '8', '8.0', '8.0.1', '8.0.1a2']
>>> get_version_hierarchy('8.0.1a2.dev')
['', '8', '8.0', '8.0.1', '8.0.1a2', '8.0.1a2.dev']
"""
base = [str(i) for i in packaging.version.Version(version).release]
smart_ver = packaging.version.Version(version)
base = [str(i) for i in smart_ver.release]
hierarchy = ['']
hierarchy += ['.'.join(base[:i+1]) for i in range(len(base))]
hierarchy += ['.'.join(base[:i]) for i in range(1, len(base) + 1)]
if smart_ver.pre:
hierarchy.append(
hierarchy[-1] + ''.join(str(i) for i in smart_ver.pre))
if version not in hierarchy:
hierarchy.append(version)
return hierarchy
Expand Down

0 comments on commit 4545763

Please sign in to comment.