Use the same rounding for width as for height in platform sections -- covers ticket...
[pyTivo.git] / Cheetah / Version.py
blob32af08aac9eea4e40aa0efe224768c0904f3e3e4
1 Version = '2.0rc7'
2 VersionTuple = (2,0,0,'candidate',7)
4 MinCompatibleVersion = '2.0rc6'
5 MinCompatibleVersionTuple = (2,0,0,'candidate',6)
7 ####
8 def convertVersionStringToTuple(s):
9 versionNum = [0,0,0]
10 releaseType = 'final'
11 releaseTypeSubNum = 0
12 if s.find('a')!=-1:
13 num, releaseTypeSubNum = s.split('a')
14 releaseType = 'alpha'
15 elif s.find('b')!=-1:
16 num, releaseTypeSubNum = s.split('b')
17 releaseType = 'beta'
18 elif s.find('rc')!=-1:
19 num, releaseTypeSubNum = s.split('rc')
20 releaseType = 'candidate'
21 else:
22 num = s
23 num = num.split('.')
24 for i in range(len(num)):
25 versionNum[i] = int(num[i])
26 if len(versionNum)<3:
27 versionNum += [0]
28 releaseTypeSubNum = int(releaseTypeSubNum)
30 return tuple(versionNum+[releaseType,releaseTypeSubNum])
33 if __name__ == '__main__':
34 c = convertVersionStringToTuple
35 print c('2.0a1')
36 print c('2.0b1')
37 print c('2.0rc1')
38 print c('2.0')
39 print c('2.0.2')
42 assert c('0.9.19b1') < c('0.9.19')
43 assert c('0.9b1') < c('0.9.19')
45 assert c('2.0a2') > c('2.0a1')
46 assert c('2.0b1') > c('2.0a2')
47 assert c('2.0b2') > c('2.0b1')
48 assert c('2.0b2') == c('2.0b2')
50 assert c('2.0rc1') > c('2.0b1')
51 assert c('2.0rc2') > c('2.0rc1')
52 assert c('2.0rc2') > c('2.0b1')
54 assert c('2.0') > c('2.0a1')
55 assert c('2.0') > c('2.0b1')
56 assert c('2.0') > c('2.0rc1')
57 assert c('2.0.1') > c('2.0')
58 assert c('2.0rc1') > c('2.0b1')