Tim Savage avatar Tim Savage committed 665565b

Added version code from django 1.5
Updated version block and bumped version to 0.2

Comments (0)

Files changed (3)

django_extras/__init__.py

-VERSION = (0, 1, 2, 'beta')
+VERSION = (0, 2, 0, 'beta', 0)
 
-def get_version(*args, **kwargs):
+def get_version():
     # Don't litter django_extras/__init__.py with all the get_version stuff.
     # Only import if it's actually called.
-    from django.utils.version import get_version
-    return get_version(*args, **kwargs)
+    from django_extras.utils.version import get_version
+    return get_version(VERSION)

django_extras/utils/__init__.py

+__author__ = 'tsavage'

django_extras/utils/version.py

+# Backported from Django 1.5.x
+def get_version(version):
+    "Returns a PEP 386-compliant version number from VERSION."
+    assert len(version) == 5
+    assert version[3] in ('alpha', 'beta', 'rc', 'final')
+
+    # Now build the two parts of the version number:
+    # main = X.Y[.Z]
+    # sub = .devN - for pre-alpha releases
+    #     | {a|b|c}N - for alpha, beta and rc releases
+
+    parts = 2 if version[2] == 0 else 3
+    main = '.'.join(str(x) for x in version[:parts])
+
+    sub = ''
+    if version[3] == 'alpha' and version[4] == 0:
+        git_changeset = get_git_changeset()
+        if git_changeset:
+            sub = '.dev%s' % git_changeset
+
+    elif version[3] != 'final':
+        mapping = {'alpha': 'a', 'beta': 'b', 'rc': 'c'}
+        sub = mapping[version[3]] + str(version[4])
+
+    return main + sub
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.