1 """The hooke module does all the legwork for Hooke_ (BE).
3 .. _hooke: http://code.google.com/p/hooke/
5 To facilitate faster loading, submodules are not imported by default.
6 The available submodules are:
12 __version__ = (0, 9, 0, 'devel', None, 'Kenzo')
15 (major, minor, release, type, patch, name)
19 * type: Python uses alpha, beta, candidate, and final. Whatever
20 so long as the alphabetic sort gets them in the right order.
21 * patch: either manually incremented for each release, the packaging
22 date string, YYYYMMDD, date of last commit, whatever.
24 See `Greg Noel's post on scons-devel`_ for a good explaination of why this
25 versioning scheme is a good idea.
27 .. _Greg Noel's post on scons-devel
28 http://thread.gmane.org/gmane.comp.programming.tools.scons.devel/8740
31 def version(depth=-1, version_tuple=None):
32 """Return a nicely formatted version string.::
34 major.minor.release.type[.patch] (name)
39 Since I seem to be unable to override __version__ in a Doctest,
40 we'll pass the version tuple in as an argument. You can ignore
43 >>> v = (1, 2, 3, 'devel', '20100501', 'Kenzo')
45 If depth -1, a full version string is returned
47 >>> version(depth=-1, version_tuple=v)
48 '1.2.3.devel.20100501 (Kenzo)'
50 Otherwise, only the first depth fields are used.
52 >>> version(depth=3, version_tuple=v)
54 >>> version(depth=4, version_tuple=v)
57 Here's an example dropping the patch.
59 >>> v = (1, 2, 3, 'devel', None, 'Kenzo')
60 >>> version(depth=-1, version_tuple=v)
63 if version_tuple == None:
64 version_tuple = __version__
66 if version_tuple[patch_index] == None: # No patch field, drop that entry
67 version_tuple = version_tuple[0:patch_index] \
68 + version_tuple[patch_index+1:]
69 if depth >= patch_index:
71 fields = version_tuple[0:depth]
72 string = '.'.join([str(x) for x in fields])
73 if depth == -1 or depth == len(version_tuple):
74 string += ' (%s)' % version_tuple[-1]