"Fossies" - the Fresh Open Source Software Archive 
Member "cheetah3-3.2.6.post2/Cheetah/Version.py" (20 Apr 2021, 1560 Bytes) of package /linux/www/cheetah3-3.2.6.post2.tar.gz:
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Python source code syntax highlighting (style:
standard) with prefixed line numbers.
Alternatively you can here
view or
download the uninterpreted source code file.
For more information about "Version.py" see the
Fossies "Dox" file reference documentation and the latest
Fossies "Diffs" side-by-side code changes report:
3-3.2.6.post1_vs_3-3.2.6.post2.
1 #!/usr/bin/env python
2
3 Version = '3.2.6.post2'
4 VersionTuple = (3, 2, 6, 'post', 2)
5
6 MinCompatibleVersion = '3.0.0a1'
7 MinCompatibleVersionTuple = (3, 0, 0, 'alpha', 1)
8
9 ####
10
11
12 def convertVersionStringToTuple(s):
13 versionNum = [0, 0, 0]
14 releaseType = 'final'
15 releaseTypeSubNum = 0
16 if s.find('a') != -1:
17 num, releaseTypeSubNum = s.split('a')
18 releaseType = 'alpha'
19 elif s.find('b') != -1:
20 num, releaseTypeSubNum = s.split('b')
21 releaseType = 'beta'
22 elif s.find('rc') != -1:
23 num, releaseTypeSubNum = s.split('rc')
24 releaseType = 'candidate'
25 else:
26 num = s
27 num = num.split('.')
28 for i in range(len(num)):
29 versionNum[i] = int(num[i])
30 if len(versionNum) < 3:
31 versionNum += [0]
32 releaseTypeSubNum = int(releaseTypeSubNum)
33
34 return tuple(versionNum + [releaseType, releaseTypeSubNum])
35
36
37 if __name__ == '__main__':
38 c = convertVersionStringToTuple
39 print(c('2.0a1'))
40 print(c('2.0b1'))
41 print(c('2.0rc1'))
42 print(c('2.0'))
43 print(c('2.0.2'))
44
45 assert c('0.9.19b1') < c('0.9.19')
46 assert c('0.9b1') < c('0.9.19')
47
48 assert c('2.0a2') > c('2.0a1')
49 assert c('2.0b1') > c('2.0a2')
50 assert c('2.0b2') > c('2.0b1')
51 assert c('2.0b2') == c('2.0b2')
52
53 assert c('2.0rc1') > c('2.0b1')
54 assert c('2.0rc2') > c('2.0rc1')
55 assert c('2.0rc2') > c('2.0b1')
56
57 assert c('2.0') > c('2.0a1')
58 assert c('2.0') > c('2.0b1')
59 assert c('2.0') > c('2.0rc1')
60 assert c('2.0.1') > c('2.0')
61 assert c('2.0rc1') > c('2.0b1')