forked from GoaFan77/Enhanced4XModRepo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSins_manifest_updater.py
77 lines (63 loc) · 1.78 KB
/
Sins_manifest_updater.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
##Sins Manifest Updater By GoaFan77
##Version 1.0 2-2-12
import os, sys
def GetPath(): #gets the path of the current directory
path = sys.argv[0]
print(path)
for i in range(-1, -100, -1):
if path[i] == "\\":
return path[0:i]
break
else:
i = i-1
print("Path not recognized/file name too long")
quit
def ReadManifest(): #reads the manifest.entity file of the current directory
infile = open('entity.manifest', 'r')
infile.readline()
num = infile.readline()
num = num.split()
num = int(num[1])
manifest = infile.read()
manifest = manifest.rstrip('\n')
infile.close()
infile = open('entity.manifest', 'r')
infile.readline()
infile.readline()
entitylist = {}
for i in range (2, num+2):
line = infile.readline()
line = line.rstrip('\n')
line = line[11:]
line = line.lstrip('"')
line = line.rstrip('"')
entitylist[line] = True
infile.close()
return num, entitylist, manifest
def CopyManifest():
infile = open('entity.manifest', 'r')
outfile = open ("Oldentity.manifest", 'w')
file = infile.read()
infile.close()
outfile.write(file)
outfile.close()
def main():
CopyManifest()
path = GetPath()
path = path + "/GameInfo"
num, entityList, manifest = ReadManifest()
newEntities = []
listing = os.listdir(path)
for infile in listing:
if infile[-7:] == '.entity':
if not infile in entityList:
print(infile)
newEntities.append(infile)
for i in newEntities:
manifest = manifest + '\nentityName "' + i + '"'
num += 1
manifest = "TXT\nentityNameCount " + str(num) +'\n'+ manifest + "\n"
outfile = open ("entity.manifest", 'w')
outfile.write(manifest)
outfile.close()
main()