forked from PTSnoop/HoI4-to-Stellaris-Converter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
getCountryNames.py
54 lines (40 loc) · 1.57 KB
/
getCountryNames.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
#!/usr/bin/python3
import os,sys
import re,yaml
import naive_parser
def getCountryNames(hoi4path):
countryNameYmlPath = hoi4path + "localisation/countries_mod_l_english.yml"
if not os.path.exists(countryNameYmlPath):
countryNameYmlPath = hoi4path + "localisation/countries_l_english.yml"
ymlData = open(countryNameYmlPath).read()
ymlData = "\n".join(ymlData.split("\n")[1:])[1:]
ymlData = re.sub(r':[0-9]*',r':', ymlData)
ymlData = re.sub(r'\n ',r'\n', ymlData)
ymlData = ymlData.encode("ascii",errors="ignore")
countryNames = yaml.load(ymlData)
# if isinstance(countryNames, str):
# # I have to do everything myself around here
# countryNames = {}
# for line in ymlData.split('\n'):
# print(line)
# tag = line.split(":")[0]
# print(tag)
# quotes = line.split("\"")
# if len(quotes) == 2:
# name = line.split("\"")[1]
# print(name)
# countryNames[tag] = name
return countryNames
def getCityNames(hoi4path):
countryNameYmlPath = hoi4path + "localisation/victory_points_l_english.yml"
try:
ymlData = open(countryNameYmlPath).read()
except:
data = open(countryNameYmlPath, 'rb').read()
ymlData = data.decode("utf8", "ignore")
ymlData = "\n".join(ymlData.split("\n")[1:])[1:]
ymlData = re.sub(r':[0-9]*',r':', ymlData)
ymlData = re.sub(r'\n ',r'\n', ymlData)
ymlData = ymlData.encode("ascii",errors="ignore")
cityNames = yaml.load(ymlData)
return list(cityNames.values())