-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOfflineInstaller.py
More file actions
61 lines (47 loc) · 1.75 KB
/
OfflineInstaller.py
File metadata and controls
61 lines (47 loc) · 1.75 KB
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
from shutil import copyfile
STARTING_LINE = 4
LINE_SKIP = 1
NEW_FILE_NAME = "NewREDGame.uexp"
UPDATE_FILE_NAME = "REDGameUpdate.uexp"
OLD_FILE_NAME = "REDGame.uexp"
def ReadFileOffline(fileName):
file = open(fileName, "r", encoding="utf-16 le", errors="ignore")
lineList = file.read().splitlines()
return lineList
def CompareFileString(oldLineList, newLineList):
oldLine = STARTING_LINE
newLine = STARTING_LINE
oldLineListLen = len(oldLineList)
newLineListLen = len(newLineList)
while oldLine + LINE_SKIP * 2 < oldLineListLen and newLine + LINE_SKIP * 2 < newLineListLen:
if oldLineList[oldLine] == newLineList[newLine]:
oldLine += LINE_SKIP
newLine += LINE_SKIP
if oldLineList[oldLine] != newLineList[newLine]:
newLineList[newLine] = oldLineList[oldLine]
oldLine += LINE_SKIP
newLine += LINE_SKIP
else:
newLine += LINE_SKIP * 2
return newLineList
def WriteNewFile(newLineList):
copyfile(UPDATE_FILE_NAME, NEW_FILE_NAME)
file = open(NEW_FILE_NAME, "r+", encoding="utf-16 le", errors="replace")
for i in range(STARTING_LINE):
file.readline()
size = file.tell()
file.seek(0, 1)
file.truncate(size)
for i in range(STARTING_LINE, len(newLineList)):
file.write(newLineList[i] + "\n")
print("Donetes have fun luv")
#inputRegion = input("Enter region code of the uexp file to update: ").upper()
#newLineList = ReadFileOnline(inputRegion)
newLineList = ReadFileOffline(UPDATE_FILE_NAME)
if newLineList[0] != "Not Found":
oldLineList = ReadFileOffline(OLD_FILE_NAME)
newLineList = CompareFileString(oldLineList, newLineList)
WriteNewFile(newLineList)
else:
print(newLineList[0])
input()