1
|
|
|
# Copyright 2013 Mathias WOLFF |
2
|
|
|
# This file is part of pyfreebilling. |
3
|
|
|
# |
4
|
|
|
# pyfreebilling is free software: you can redistribute it and/or modify |
5
|
|
|
# it under the terms of the GNU General Public License as published by |
6
|
|
|
# the Free Software Foundation, either version 3 of the License, or |
7
|
|
|
# (at your option) any later version. |
8
|
|
|
# |
9
|
|
|
# pyfreebilling is distributed in the hope that it will be useful, |
10
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
11
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12
|
|
|
# GNU General Public License for more details. |
13
|
|
|
# |
14
|
|
|
# You should have received a copy of the GNU General Public License |
15
|
|
|
# along with pyfreebilling. If not, see <http://www.gnu.org/licenses/> |
16
|
|
|
# |
17
|
|
|
# Initial code from tarak : https://github.com/tarak/django-password-policies |
18
|
|
|
# Modified by Mathias WOLFF |
19
|
|
|
|
20
|
|
|
from django.utils.version import get_git_changeset |
21
|
|
|
|
22
|
|
|
|
23
|
|
|
VERSION = (1, 4, 7, 'final', 0) |
24
|
|
|
|
25
|
|
|
|
26
|
|
|
def get_version(version=None): |
27
|
|
|
"""Derives a PEP386-compliant version number from VERSION.""" |
28
|
|
|
if version is None: |
29
|
|
|
version = VERSION |
30
|
|
|
assert len(version) == 5 |
31
|
|
|
assert version[3] in ('alpha', 'beta', 'rc', 'final') |
32
|
|
|
|
33
|
|
|
# Now build the two parts of the version number: |
34
|
|
|
# main = X.Y[.Z] |
35
|
|
|
# sub = .devN - for pre-alpha releases |
36
|
|
|
# | {a|b|c}N - for alpha, beta and rc releases |
37
|
|
|
|
38
|
|
|
parts = 2 if version[2] == 0 else 3 |
39
|
|
|
main = '.'.join(str(x) for x in version[:parts]) |
40
|
|
|
|
41
|
|
|
sub = '' |
42
|
|
|
if version[3] == 'alpha' and version[4] == 0: |
43
|
|
|
# At the toplevel, this would cause an import loop. |
44
|
|
|
git_changeset = get_git_changeset() |
45
|
|
|
if git_changeset != 'unknown': |
46
|
|
|
sub = '.dev%s' % git_changeset |
47
|
|
|
|
48
|
|
|
elif version[3] != 'final': |
49
|
|
|
mapping = {'alpha': 'a', 'beta': 'b', 'rc': 'c'} |
50
|
|
|
sub = mapping[version[3]] + str(version[4]) |
51
|
|
|
|
52
|
|
|
return main + sub |
53
|
|
|
|
54
|
|
|
|
55
|
|
|
__version__ = get_version() |
56
|
|
|
|