Fix hooke.version(4) with missing patch index.
authorW. Trevor King <wking@drexel.edu>
Fri, 17 Feb 2012 03:08:53 +0000 (22:08 -0500)
committerW. Trevor King <wking@drexel.edu>
Fri, 17 Feb 2012 03:08:53 +0000 (22:08 -0500)
hooke/__init__.py

index 9a04fec08a258758c4df9f485e650b1857552bf0..2b552ee13ad59d9866826c29c55ae18832f947a5 100644 (file)
@@ -89,6 +89,8 @@ def version(depth=-1, version_tuple=None):
     >>> v = (1, 2, 3, 'devel', None, 'Kenzo')
     >>> version(depth=-1, version_tuple=v)
     '1.2.3.devel (Kenzo)'
+    >>> version(depth=4, version_tuple=v)
+    '1.2.3.devel'
     """
     if version_tuple == None:
         version_tuple = __version__
@@ -96,7 +98,7 @@ def version(depth=-1, version_tuple=None):
     if version_tuple[patch_index] == None: # No patch field, drop that entry
         version_tuple = version_tuple[0:patch_index] \
             + version_tuple[patch_index+1:]
-        if depth >= patch_index:
+        if depth > patch_index:
             depth -= 1
     fields = version_tuple[0:depth]
     string = '.'.join([str(x) for x in fields])