forked from codywd/NetGUI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
UpdateVersions.py
78 lines (62 loc) · 2.41 KB
/
UpdateVersions.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import xml.etree.ElementTree as ET
import fileinput
progVer = "0.7.5"
# Automatic Glade Version Setter, thanks to Dane White
# at the Stack Overflow forums!
class ProgramProperties(object):
def __init__(self, xmlfile):
# Parse the XML file
self.__xmlfile = xmlfile
self.__xml_tree = ET.parse(xmlfile)
self.__version_element = self.__xml_tree.getroot().find(".//property[@name='version']")
# Get an in-memory copy of 'version'
self.__version = self.__version_element.text
@property
def version(self):
return self.__version
@version.setter
def version(self, vers):
# Avoid unecessary file I/O
if self.__version != vers:
# Store in-memory
self.__version = vers
# Save the version to the file
self.__version_element.text = str(vers)
self.__xml_tree.write(self.__xmlfile)
class ModifyOtherVers():
def __init__(self):
ModifyOtherVers.updatePkgBuild()
def updatePkgBuild():
PKGBUILD = ("scripts/PKGBUILD")
for line in fileinput.input(PKGBUILD, inplace=True):
if "pkgver=" in line:
print(line.replace(line, "pkgver=" + str(prog.version)))
else:
print(line.strip())
ModifyOtherVers.updateSetupPy()
def updateSetupPy():
SetupPy = ("setup.py")
for line in fileinput.input(SetupPy, inplace=True):
if "version" in line:
print(line.replace(line, " version='" + str(prog.version) + "',"))
else:
print(line.rstrip("\n"))
ModifyOtherVers.updateMainFile()
def updateMainFile():
mainFile = ("main.py")
for line in fileinput.input(mainFile, inplace=True):
if "progVer =" in line:
print(line.replace(line, 'progVer = "' + prog.version + '"'))
else:
print(line.rstrip("\n"))
ModifyOtherVers.UpdateReadme()
def UpdateReadme():
README = ("README.md")
for line in fileinput.input(README, inplace=True):
if "# NetGUI v" in line:
print(line.replace(line, "# NetGUI v" + prog.version))
else:
print(line.rstrip("\n"))
prog = ProgramProperties('UI.glade')
prog.version = progVer
ModifyOtherVers.updatePkgBuild()