-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathpreparerelease.py
executable file
·47 lines (34 loc) · 972 Bytes
/
preparerelease.py
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
VERSION = raw_input().strip()
def replace(filename):
fh = open(filename, "r")
content = fh.read()
content = content.replace("_VERSION_", VERSION)
fh.close()
fh = open(filename.replace("_draft", ""), "w")
fh.write(content)
fh.close()
def replace_line(filename):
line_to_search_for = "#!!Version line "
rep = False
fh = open(filename, "r")
content = fh.read()
fh.close()
output = ""
for line in content.split("\n"):
if line_to_search_for in line:
rep = True
line = "VERSION=\"%s\" %s" % (VERSION, line_to_search_for)
# print "replaced"
output += line + "\n"
# if not rep:
# print "Did not replace any line"
fh = open(filename, "w")
fh.write(output[0:-1])
fh.close()
replace("about.glade_draft")
replace("control_draft")
replace_line("modules/functions.py")
print VERSION