1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 """ S60 Version Management module.
21
22 ::
23
24 config = {'model.name': 'NXX',
25 'variant.id': '01',
26 'variant.revision' : '0',
27 'model.template': '${model.name} (${variant.id}.${variant.revision})'}
28 v = Version('model',config)
29 print v.version_string()
30
31 """
32
33 from datetime import date
34 import codecs
35 import os
36 import re
37
39 """ Version template.
40 """
42 """ Initialise the Version object.
43 """
44 self.vtype = vtype
45 self.config = config
46 today = date.today().strftime( "%d-%m-%y" )
47 self.config['today'] = today
48
50 """ Returns the formatted version string.
51 """
52
53
54 return self.__unescape(self.config["%s.template" % self.vtype])
55
57 """ Write the version string to the vtype.txt.path file.
58 """
59 self.__write(self.__unescape(self.config["%s.txt.path" % self.vtype]), self.version_string())
60
61 - def __write( self, path, content ):
72
73
75 previous = u''
76 while previous != text:
77 previous = text
78 text = re.sub(r'\${(?P<name>[._a-zA-Z0-9]+)}', r'%(\g<name>)s', text)
79 text = text % self.config
80 return text
81
82
84 """ The string representation of the version object is the full version string.
85 """
86 return self.version_string()
87