File: incBuildNumber.py

package info (click to toggle)
yoshimi 2.3.6-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 17,012 kB
  • sloc: cpp: 62,589; xml: 97; sh: 94; python: 45; makefile: 14
file content (29 lines) | stat: -rw-r--r-- 600 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/env python

def increment(line):
    numbertext = line[len(endstring):]
    if numbertext > " ":
        return str(int(numbertext) + 1)
    else:
        return "0"


f = open("../src/Misc/ConfBuild.h","r+")
line = "start"
found = 0
endstring = "#define BUILD_NUMBER"
text = "0"
while line != "" and found == 0:
    mark = f.tell()
    line = f.readline()
    if endstring in line:
        found = mark
        text = increment(line)

if found == 0:
    found = mark
f.seek(found)
f.write("#define BUILD_NUMBER " + text + "\n")
f.truncate()
f.close()
print("BUILD_NUMBER " + text + "\n")