Fix hooke.version(4) with missing patch index.
[hooke.git] / hooke / __init__.py
index 283d0dd2955b6ee28a46a9d04402a32bbe532752..2b552ee13ad59d9866826c29c55ae18832f947a5 100644 (file)
@@ -1,4 +1,19 @@
-# COPYRIGHT
+# Copyright (C) 2010-2012 W. Trevor King <wking@drexel.edu>
+#
+# This file is part of Hooke.
+#
+# Hooke is free software: you can redistribute it and/or modify it under the
+# terms of the GNU Lesser General Public License as published by the Free
+# Software Foundation, either version 3 of the License, or (at your option) any
+# later version.
+#
+# Hooke is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+# A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
+# details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with Hooke.  If not, see <http://www.gnu.org/licenses/>.
 
 """The hooke module does all the legwork for Hooke_.
 
@@ -11,7 +26,20 @@ The available submodules are:
 * :mod:`hooke.compat`
 """
 
-__version__ = (0, 9, 0, 'devel', None, 'Kenzo')
+import sys as _sys
+
+try:
+    from .license import LICENSE as __license__
+except ImportError as e:
+    import logging
+    logging.warn('could not load LICENSE from hooke.license')
+    __license__ = 'All rights reserved.' 
+
+if _sys.version_info < (3,0):
+    # yaml library not yet compatible with Python 3
+    from .util import yaml  # extend YAML to parse Hooke-specific items.
+
+__version__ = (1, 0, 0, 'alpha', None, 'Ninken')
 """Version tuple::
 
     (major, minor, release, type, patch, name)
@@ -61,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__
@@ -68,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])