Skip to content

Commit

Permalink
[version] Improved get_version to follow PEP440
Browse files Browse the repository at this point in the history
  • Loading branch information
nemesifier committed Jul 10, 2017
1 parent b76e4e2 commit c4c9ba2
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions openwisp_controller/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@


def get_version():
version = '%s.%s.%s' % (VERSION[0], VERSION[1], VERSION[2])
if VERSION[3] != 'final':
first_letter = VERSION[3][0:1]
try:
suffix = VERSION[4]
except IndexError:
suffix = 0
version = '%s%s%s' % (version, first_letter, suffix)
version = '%s.%s' % (VERSION[0], VERSION[1])
if VERSION[2]:
version = '%s.%s' % (version, VERSION[2])
if VERSION[3:] == ('alpha', 0):
version = '%s pre-alpha' % version
else:
if VERSION[3] != 'final':
try:
rev = VERSION[4]
except IndexError:
rev = 0
version = '%s%s%s' % (version, VERSION[3][0:1], rev)
return version

0 comments on commit c4c9ba2

Please sign in to comment.