-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathruleloader.py
50 lines (44 loc) · 1.62 KB
/
ruleloader.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
def load_code_changes(filename):
code_changes = {}
with open(filename, encoding="utf-8") as f:
for line in f:
cells = line.strip().split(",")
change_year = int(cells[0].split("-")[1])
old = cells[1]
new = cells[2]
if change_year not in code_changes:
code_changes[change_year] = {}
code_changes[change_year][old] = new
return code_changes
def load_name_changes(filename):
name_changes = {}
with open(filename, encoding="utf-8") as f:
for line in f:
cells = line.strip().split(",")
change_year = int(cells[0].split("-")[1])
code = cells[1]
if change_year not in name_changes:
name_changes[change_year] = {}
name_changes[change_year][code] = code
return name_changes
def load_merges(filename):
merges = {}
with open(filename, encoding="utf-8") as f:
for line in f:
[change_year, old, new] = line.strip().split(",")
change_year = int(change_year)
if change_year not in merges:
merges[change_year] = {}
merges[change_year][old] = new
return merges
def load_splits(filename):
splits = {}
with open(filename, encoding="utf-8") as f:
for line in f:
cells = line.strip().split(",")
change_year = int(cells[0])
old = cells[1]
if change_year not in splits:
splits[change_year] = {}
splits[change_year][old] = cells[2:]
return splits