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

Function loadmap_jisx0213

Tools/unicode/genmap_japanese.py:30–72  ·  view source on GitHub ↗
(fo)

Source from the content-addressed store, hash-verified

28
29
30def loadmap_jisx0213(fo):
31 decmap3, decmap4 = {}, {} # maps to BMP for level 3 and 4
32 decmap3_2, decmap4_2 = {}, {} # maps to U+2xxxx for level 3 and 4
33 decmap3_pair = {} # maps to BMP-pair for level 3
34 for line in fo:
35 line = line.split('#', 1)[0].strip()
36 if not line or len(line.split()) < 2:
37 continue
38
39 row = line.split()
40 loc = eval('0x' + row[0][2:])
41 level = eval(row[0][0])
42 m = None
43 if len(row[1].split('+')) == 2: # single unicode
44 uni = eval('0x' + row[1][2:])
45 if level == 3:
46 if uni < 0x10000:
47 m = decmap3
48 elif 0x20000 <= uni < 0x30000:
49 uni -= 0x20000
50 m = decmap3_2
51 elif level == 4:
52 if uni < 0x10000:
53 m = decmap4
54 elif 0x20000 <= uni < 0x30000:
55 uni -= 0x20000
56 m = decmap4_2
57 m.setdefault((loc >> 8), {})
58 m[(loc >> 8)][(loc & 0xff)] = uni
59 else: # pair
60 uniprefix = eval('0x' + row[1][2:6]) # body
61 uni = eval('0x' + row[1][7:11]) # modifier
62 if level != 3:
63 raise ValueError("invalid map")
64 decmap3_pair.setdefault(uniprefix, {})
65 m = decmap3_pair[uniprefix]
66
67 if m is None:
68 raise ValueError("invalid map")
69 m.setdefault((loc >> 8), {})
70 m[(loc >> 8)][(loc & 0xff)] = uni
71
72 return decmap3, decmap4, decmap3_2, decmap4_2, decmap3_pair
73
74
75def main():

Callers 1

mainFunction · 0.85

Calls 3

stripMethod · 0.45
splitMethod · 0.45
setdefaultMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…