-
Notifications
You must be signed in to change notification settings - Fork 3
/
_sreplace.py
37 lines (33 loc) · 1.52 KB
/
_sreplace.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
#-*- coding: utf-8 -*-
import sys
# import fileinput
# import codecs
import in_place
if (len(sys.argv) - 1) != 0:
version = sys.argv[1]
versionComma = version.replace('.', ', ')+' ,0'
else:
print('No version number defined. Exiting...')
exit()
# version = '2.1.3'
# versionComma = version.replace('.', ', ')+' ,0'
def _sReplace(filename, search, replace, unixEol=False):
# with fileinput.FileInput(filename, openhook=fileinput.hook_encoded("utf-8"), inplace=True) as file:
# for line in file:
# print(line.replace(search, replace), end='')
with in_place.InPlace(filename, encoding="utf-8") as file:
for line in file:
file.write(line.replace(search, replace))
if unixEol:
fileContents = open(filename,"r", encoding="utf-8").read()
f = open(filename,"w", encoding="utf-8", newline="\n")
f.write(fileContents)
f.close()
_sReplace('build/win/main.py', '1.0.0', version, False) #main.py win
_sReplace('build/win/version.txt', '1, 0, 0, 0', versionComma, False) #version.txt
_sReplace('build/win/dist/setupgen.iss', '1.0.0', version, False) #setupgen.iss
_sReplace('build/osx/main.py', '1.0.0', version, False) #main.py osx
_sReplace('build/osx/_build.run', '1.0.0', version, True) #_build.run
_sReplace('build/osx/dist/setupgen.pkgproj', '1.0.0', version, True) #setupgen.pkgproj
_sReplace('build/lin/dist/deb-package/DEBIAN/control', '1.0.0', version, False) #control
_sReplace('build/lin/main.py', '1.0.0', version, False) #main.py win