MCPcopy Index your code
hub / github.com/python/cpython / main

Function main

Tools/unicode/genmap_korean.py:21–58  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

19
20
21def main():
22 mapfile = open_mapping_file('python-mappings/CP949.TXT', MAPPINGS_CP949)
23 print("Loading Mapping File...")
24 decmap = loadmap(mapfile)
25 uhcdecmap, ksx1001decmap, cp949encmap = {}, {}, {}
26 for c1, c2map in decmap.items():
27 for c2, code in c2map.items():
28 if c1 >= 0xa1 and c2 >= 0xa1:
29 ksx1001decmap.setdefault(c1 & 0x7f, {})
30 ksx1001decmap[c1 & 0x7f][c2 & 0x7f] = c2map[c2]
31 cp949encmap.setdefault(code >> 8, {})
32 cp949encmap[code >> 8][code & 0xFF] = (c1 << 8 | c2) & 0x7f7f
33 else:
34 # uhc
35 uhcdecmap.setdefault(c1, {})
36 uhcdecmap[c1][c2] = c2map[c2]
37 cp949encmap.setdefault(code >> 8, {}) # MSB set
38 cp949encmap[code >> 8][code & 0xFF] = (c1 << 8 | c2)
39
40 with open('mappings_kr.h', 'w') as fp:
41 print_autogen(fp, os.path.basename(__file__))
42
43 print("Generating KS X 1001 decode map...")
44 writer = DecodeMapWriter(fp, "ksx1001", ksx1001decmap)
45 writer.update_decode_map(KSX1001_C1, KSX1001_C2)
46 writer.generate()
47
48 print("Generating UHC decode map...")
49 writer = DecodeMapWriter(fp, "cp949ext", uhcdecmap)
50 writer.update_decode_map(UHCL1_C1, UHCL1_C2)
51 writer.update_decode_map(UHCL2_C1, UHCL2_C2)
52 writer.generate()
53
54 print("Generating CP949 (includes KS X 1001) encode map...")
55 writer = EncodeMapWriter(fp, "cp949", cp949encmap)
56 writer.generate()
57
58 print("Done!")
59
60
61if __name__ == '__main__':

Callers 1

genmap_korean.pyFile · 0.70

Calls 11

generateMethod · 0.95
open_mapping_fileFunction · 0.85
loadmapFunction · 0.85
print_autogenFunction · 0.85
DecodeMapWriterClass · 0.85
EncodeMapWriterClass · 0.85
update_decode_mapMethod · 0.80
openFunction · 0.50
itemsMethod · 0.45
setdefaultMethod · 0.45
basenameMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…