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