X-Git-Url: http://git.tremily.us/?p=hooke.git;a=blobdiff_plain;f=hooke%2F__init__.py;h=2b552ee13ad59d9866826c29c55ae18832f947a5;hp=a220d8b26cff0ab8a580a8c7ba6317bf4d4d5331;hb=9a7935eb875f407b9ec561bcbb9d00c283787c8b;hpb=07d84098df5efe5db97461a0568c813f634ea117 diff --git a/hooke/__init__.py b/hooke/__init__.py index a220d8b..2b552ee 100644 --- a/hooke/__init__.py +++ b/hooke/__init__.py @@ -1,20 +1,19 @@ -# Copyright (C) 2010 W. Trevor King +# Copyright (C) 2010-2012 W. Trevor King # # 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 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. +# 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 -# . +# You should have received a copy of the GNU Lesser General Public License +# along with Hooke. If not, see . """The hooke module does all the legwork for Hooke_. @@ -26,14 +25,19 @@ The available submodules are: * :mod:`hooke.config` * :mod:`hooke.compat` """ + +import sys as _sys + try: from .license import LICENSE as __license__ -except ImportError, e: +except ImportError as e: import logging logging.warn('could not load LICENSE from hooke.license') __license__ = 'All rights reserved.' -from .util import yaml # extend YAML to parse Hooke-specific items. +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:: @@ -85,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__ @@ -92,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])