/[thuban]/branches/WIP-pyshapelib-bramz/Thuban/Lib/version.py
ViewVC logotype

Annotation of /branches/WIP-pyshapelib-bramz/Thuban/Lib/version.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2011 - (hide annotations)
Wed Dec 3 09:46:27 2003 UTC (21 years, 3 months ago) by bh
Original Path: trunk/thuban/Thuban/Lib/version.py
File MIME type: text/x-python
File size: 1044 byte(s)
* Thuban/Lib/version.py: New. Module for version number
manipulations. The version of make_tuple here also deals better
with more unusual version number strings, such as e.g.
"1.2+cvs20031111"

* Thuban/version.py (make_tuple): Removed. It's now in
Thuban.Lib.version. Use that implementation instead.

* test/test_lib_version.py: New. Tests for Thuban/Lib/version.py

1 bh 2011 # Copyright (C) 2003 by Intevation GmbH
2     # Authors:
3     # Bernhard Herzog <[email protected]>
4     #
5     # This program is free software under the GPL (>=v2)
6     # Read the file COPYING coming with the software for details.
7    
8     """Version number handling"""
9    
10     __version__ = "$Revision$"
11     # $Source$
12     # $Id$
13    
14    
15     import re
16    
17     rx_version = re.compile("[0-9]+(\\.[0-9]+)*")
18    
19     def make_tuple(s):
20     """Return a tuple version of the version number string s
21    
22     The version string must start with a sequence of decimal integers
23     separated by dots. The return value is a tuple of up to three
24     integers, one for each number at the beginnin of the version string.
25    
26     If the string does not start with a number return None
27    
28     Examples:
29     >>> import version
30     >>> version.make_tuple('1.2')
31     (1, 2)
32     >>> version.make_tuple('2.4.0.7')
33     (2, 4, 0)
34     >>> version.make_tuple('1.2+cvs.20031111')
35     (1, 2)
36     >>> version.make_tuple('foo')
37     >>>
38     """
39     match = rx_version.match(s)
40     if match:
41     return tuple(map(int, match.group(0).split(".")[:3]))
42    

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26