diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2012-11-14 09:47:16 +0100 |
---|---|---|
committer | Jelmer Vernooij <jelmer@samba.org> | 2012-11-14 12:11:57 +0100 |
commit | a53caea7a27c8616cabfc2e5bdf91a90e35891d5 (patch) | |
tree | 5e1ad6e0387c076cc41d14213efbe4457d861690 /lib/subunit/setup.py | |
parent | 7b654a8c180a6467147189332916a5e56634b5af (diff) | |
download | samba-a53caea7a27c8616cabfc2e5bdf91a90e35891d5.tar.gz samba-a53caea7a27c8616cabfc2e5bdf91a90e35891d5.tar.bz2 samba-a53caea7a27c8616cabfc2e5bdf91a90e35891d5.zip |
subunit: Update to latest upstream version.
Autobuild-User(master): Jelmer Vernooij <jelmer@samba.org>
Autobuild-Date(master): Wed Nov 14 12:11:58 CET 2012 on sn-devel-104
Diffstat (limited to 'lib/subunit/setup.py')
-rwxr-xr-x | lib/subunit/setup.py | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/lib/subunit/setup.py b/lib/subunit/setup.py index bb51a24fcc..a78eb999d7 100755 --- a/lib/subunit/setup.py +++ b/lib/subunit/setup.py @@ -13,19 +13,22 @@ else: ] } -try: + +def _get_version_from_file(filename, start_of_line, split_marker): + """Extract version from file, giving last matching value or None""" + try: + return [x for x in open(filename) + if x.startswith(start_of_line)][-1].split(split_marker)[1].strip() + except (IOError, IndexError): + return None + + +VERSION = ( # Assume we are in a distribution, which has PKG-INFO - version_lines = [x for x in open('PKG-INFO').readlines() - if x.startswith('Version:')] - version_line = version_lines and version_lines[-1] or 'VERSION = 0.0' - VERSION = version_line.split(':')[1].strip() - -except IOError: + _get_version_from_file('PKG-INFO', 'Version:', ':') # Must be a development checkout, so use the Makefile - version_lines = [x for x in open('Makefile').readlines() - if x.startswith('VERSION')] - version_line = version_lines and version_lines[-1] or 'VERSION = 0.0' - VERSION = version_line.split('=')[1].strip() + or _get_version_from_file('Makefile', 'VERSION', '=') + or "0.0") setup( |