forked from PTSnoop/HoI4-to-Stellaris-Converter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
readConfig.py
55 lines (41 loc) · 1.69 KB
/
readConfig.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
#!/usr/bin/python3
import sys
import os.path
import naive_parser
def reformatPath(path, isDir):
path = path.replace("\\","/")
if path[0] == '"' and path[-1] == '"':
path = path[1:-1]
if isDir and path[-1] != "/":
path += "/"
return path
class Config:
def __init__(self):
print("Parsing configuration")
self.configfile = naive_parser.ParseSaveFile("configuration.txt")
self.savefile = naive_parser.drill(self.configfile, "configuration", "savefile")
self.hoi4path = naive_parser.drill(self.configfile, "configuration", "HoI4directory")
self.targetdir = naive_parser.drill(self.configfile, "configuration", "StellarisModdirectory")
print("Save file: "+self.savefile)
print("HoI4 location: "+self.hoi4path)
print("Stellaris mod path: "+self.targetdir)
self.savefile = reformatPath(self.savefile, False)
self.hoi4path = reformatPath(self.hoi4path, True)
self.targetdir = reformatPath(self.targetdir, True)
if not self.savefile:
print("Error: Could not parse save file.")
sys.exit(1)
if not self.hoi4path:
print("Error: Could not parse HoI4 path.")
sys.exit(1)
if not self.targetdir:
print("Warning: Could not parse Stellaris mod path. Mod will only be created in the converter directory.")
for path in [self.savefile, self.hoi4path, self.targetdir]:
if not os.path.exists(path):
print("Error: Could not find "+path)
sys.exit(1)
if __name__ == "__main__":
config = Config()
print(config.savefile)
print(config.hoi4path)
print(config.targetdir)