Skip to content
This repository was archived by the owner on Nov 13, 2024. It is now read-only.

Commit ef5b984

Browse files
committed
Black, update code list, add synonyms
1 parent 6d1c183 commit ef5b984

File tree

7 files changed

+16814
-223
lines changed

7 files changed

+16814
-223
lines changed

languagecodes/generate.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,36 +21,35 @@ def update_data():
2121
iso3_map = {}
2222

2323
path = os.path.dirname(__file__)
24-
source_file = os.path.join(path, 'iso-639-3.tab')
25-
with io.open(source_file, 'r', encoding='utf-8') as ufh:
26-
ufh.read(1) # BOM
27-
for row in csv.DictReader(ufh, delimiter='\t'):
28-
iso3 = normalize_code(row.pop('Id'))
24+
source_file = os.path.join(path, "iso-639-3.tab")
25+
with io.open(source_file, "r", encoding="utf-8") as ufh:
26+
for row in csv.DictReader(ufh, delimiter="\t"):
27+
iso3 = normalize_code(row.pop("Id"))
2928
if iso3 is None:
3029
continue
3130
iso3_ids.add(iso3)
3231

33-
part1 = normalize_code(row.pop('Part1'))
32+
part1 = normalize_code(row.pop("Part1"))
3433
if part1 is not None:
3534
iso3_map[part1] = iso3
3635
iso2_map[iso3] = part1
3736

38-
part2b = normalize_code(row.pop('Part2B'))
37+
part2b = normalize_code(row.pop("Part2B"))
3938
if part2b is not None:
4039
iso3_map[part2b] = iso3
4140

42-
part2t = normalize_code(row.pop('Part2T'))
41+
part2t = normalize_code(row.pop("Part2T"))
4342
if part2t is not None:
4443
iso3_map[part2t] = iso3
4544

46-
ref_name = normalize_code(row.pop('Ref_Name'))
45+
ref_name = normalize_code(row.pop("Ref_Name"))
4746
if ref_name is not None:
4847
iso3_map[ref_name] = iso3
4948

5049
# print(row)
5150

52-
code_file = os.path.join(path, 'iso639.py')
53-
with io.open(code_file, 'w', encoding='utf-8') as ofh:
51+
code_file = os.path.join(path, "iso639.py")
52+
with io.open(code_file, "w", encoding="utf-8") as ofh:
5453
data = TEMPLATE % (list(iso3_ids), iso3_map, iso2_map)
5554
ofh.write(data)
5655

@@ -68,5 +67,5 @@ def update_data():
6867
# print(iso3, iso2)
6968

7069

71-
if __name__ == '__main__':
70+
if __name__ == "__main__":
7271
update_data()

0 commit comments

Comments
 (0)