forked from ggtracker/sc2reader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
new_units.py
38 lines (33 loc) · 1.25 KB
/
new_units.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
# Shows new data entries from the requested build files:
#
# Usage: python new_units.py sc2reader/data/HotS/24764_units.csv sc2reader/data/HotS/24764_abilites.csv
#
# The output from this can be used to update the unit_lookup.csv and ability_lookup.csv files. Maybe the
# script can be fixed to append these lines automatically...
#
import pkgutil
import sys
UNIT_LOOKUP = dict()
for entry in pkgutil.get_data("sc2reader.data", "unit_lookup.csv").split("\n"):
if not entry:
continue
str_id, title = entry.strip().split(",")
UNIT_LOOKUP[str_id] = title
with open(sys.argv[1]) as new_units:
for line in new_units:
new_unit_name = line.strip().split(",")[1]
if new_unit_name not in UNIT_LOOKUP:
print(f"{new_unit_name},{new_unit_name}")
print("")
print("")
ABIL_LOOKUP = dict()
for entry in pkgutil.get_data("sc2reader.data", "ability_lookup.csv").split("\n"):
if not entry:
continue
str_id, abilities = entry.split(",", 1)
ABIL_LOOKUP[str_id] = abilities.split(",")
with open(sys.argv[2]) as new_abilities:
for line in new_abilities:
new_ability_name = line.strip().split(",")[1]
if new_ability_name not in ABIL_LOOKUP:
print(f"{new_ability_name},{new_ability_name}")