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

Contents of /branches/WIP-pyshapelib-bramz/Thuban/version.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 925 - (show annotations)
Mon May 19 12:07:37 2003 UTC (21 years, 9 months ago) by frank
Original Path: trunk/thuban/Thuban/version.py
File MIME type: text/x-python
File size: 1782 byte(s)
(get_changelog_date): Catch exceptions if ChangeLog does not exist.

1 #!/usr/bin/env python
2 #
3 # Copyright (C) 2002, 2003 by Intevation GmbH
4 # Authors:
5 # Thomas Koester <[email protected]>
6 # Frank Koormann <[email protected]>
7 #
8 # This program is free software under the GPL (>=v2)
9 # Read the file COPYING coming with the software for details.
10
11 """
12 Thuban version information
13 """
14
15 __version__ = "$Revision$"
16 # $Source$
17 # $Id$
18
19
20 version = 'cvs'
21 append_date = 1
22
23
24 import os, os.path
25 import time
26
27 if __name__ == "__main__":
28 import sys
29 __file__ = sys.argv[0]
30
31 def is_relevant_file(file):
32 """check if a file is relevant for determining the current version"""
33 extensions = ['.py', '.xpm', '.c', '.h']
34 return os.path.isfile(file) and os.path.splitext(file)[1] in extensions
35
36 def visit(args, dirname, names):
37 """helper for os.path.walk; save mtime of newest file for this directory"""
38 files = filter(is_relevant_file,
39 [os.path.join(dirname, file) for file in names])
40 args['max'] = max([args['max']] + map(os.path.getmtime, files))
41
42 def get_date(format):
43 """strftime formatted mtime of the newest relevant file"""
44 dir = os.path.dirname(os.path.abspath(__file__))
45 args = {'max': 0}
46 os.path.walk(dir, visit, args)
47 return time.strftime(format, time.localtime(args['max']))
48
49 def get_changelog_date():
50 changelog = os.path.join(os.path.dirname(__file__), os.pardir, "ChangeLog")
51 try:
52 file = open(changelog, "r")
53 line = file.readline()
54 file.close()
55 except:
56 return ""
57 return '\n ChangeLog %s' % line.split(" ")[0]
58
59 if append_date:
60 version = '%s-%s' % (version, get_date('%Y%m%d'))
61 longversion = '%s%s' % (version, get_changelog_date())
62 #longversion = 'Thuban Release Version 0.2'
63
64 if __name__ == "__main__":
65 print longversion

Properties

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26