summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIsis Lovecruft <isis@torproject.org>2013-01-15 12:19:15 +0000
committerIsis Lovecruft <isis@torproject.org>2013-01-15 12:19:15 +0000
commita07f7f0d3087e83376ca8a2f23e19fe6eb23d138 (patch)
treed115570ea7036ecb0e3732f92e28db292defeb16
parent6cc3953119d0a46c9d8156dc7f958b6fb089c871 (diff)
Added versioning utility.
-rw-r--r--VERSION7
-rw-r--r--leap/util/version.py69
2 files changed, 76 insertions, 0 deletions
diff --git a/VERSION b/VERSION
new file mode 100644
index 0000000..b756111
--- /dev/null
+++ b/VERSION
@@ -0,0 +1,7 @@
+
+[leap_mx, version 0.0.1]
+------------------------
+Authors: Isis Agora Lovecruft, <isis@leap.se> 0x2cdb8b35
+Website: https://leap.se
+Github: https://github.com/isislovecruft/leap_mx/
+
diff --git a/leap/util/version.py b/leap/util/version.py
new file mode 100644
index 0000000..ecf8a22
--- /dev/null
+++ b/leap/util/version.py
@@ -0,0 +1,69 @@
+#!/usr/bin/env python
+# -*- encoding: utf-8 -*-
+'''
+version.py
+----------
+Version information for leap_mx.
+
+@authors: Isis Agora Lovecruft, <isis@leap.se> 0x2cdb8b35
+@licence: see included LICENSE file
+@copyright: 2013 Isis Agora Lovecruft
+'''
+
+import os
+
+from twisted.python import versions
+
+name = 'leap_mx'
+version = versions.Version(name, 0, 0, 1, None)
+authors = [('Isis Agora Lovecruft', '<isis@leap.se>', '0x2cdb8b35'),]
+git_url = 'https://github.com/isislovecruft/leap_mx/'
+website = 'https://leap.se'
+
+def getVersion():
+ version.authors = authors
+ version.git_url = git_url
+ version.website = website
+ return version
+
+def getRepoDir():
+ here = os.getcwd()
+ base = here.rsplit(name, 1)[0]
+ repo = os.path.join(base, name)
+ return repo
+
+def __make_text__(extra_text=None):
+ splitter = "-" * len(version.__str__())
+ header = ["\n%s\n" % version.__str__(), "%s\n" % splitter]
+ footer = ["Website: \t%s\n" % website, "Github: \t%s\n" % git_url, "\n"]
+ contacts = ["\t%s, %s %s\n" % (a[0], a[1], a[2]) for a in authors]
+ contacts.insert(0, "Authors: ")
+
+ with_contacts = header + contacts
+
+ if extra_text is not None:
+ if isinstance(extra_text, iter):
+ with_contacts.extend((e for e in extra_text))
+ elif isinstance(extra_text, str):
+ with_contacts.append(extra_text)
+ else:
+ print "Couldn't add extra text..."
+
+ text = with_contacts + footer
+ return text
+
+def __update_version__():
+ repo = getRepoDir()
+ version_file = os.path.join(repo, 'VERSION')
+ version_text = __make_text__()
+
+ with open(version_file, 'w+') as fh:
+ fh.writelines((line for line in version_text))
+ fh.flush()
+ fh.truncate()
+
+
+if __name__ == "__main__":
+ print "Generating new VERSION file..."
+ __update_version__()
+ print "Done."