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

Function parse_hkscs_map

Tools/unicode/genmap_tchinese.py:35–58  ·  view source on GitHub ↗
(fo)

Source from the content-addressed store, hash-verified

33
34
35def parse_hkscs_map(fo):
36 fo.seek(0, 0)
37 table = []
38 for line in fo:
39 line = line.split('#', 1)[0].strip()
40 # We expect 4 columns in supported HKSCS files:
41 # [1999]: unsupported
42 # [2001]: unsupported
43 # [2004]: Big-5; iso10646-1:1993; iso10646-1:2000; iso10646:2003+amd1
44 # [2008]: Big-5; iso10646-1:1993; iso10646-1:2000; iso10646:2003+amd6
45 # [2016]: not supported here--uses a json file instead
46 #
47 # In both supported cases, we only need the first and last column:
48 # * Big-5 is a hex string (always 4 digits)
49 # * iso10646:2003 is either a hex string (4 or 5 digits) or a sequence
50 # of hex strings like: `<code_point1,code_point2>`
51 try:
52 hkscs_col, _, _, uni_col = line.split()
53 hkscs = int(hkscs_col, 16)
54 seq = tuple(int(cp, 16) for cp in uni_col.strip('<>').split(','))
55 except ValueError:
56 continue
57 table.append((hkscs, seq))
58 return table
59
60
61def make_hkscs_map(table):

Callers 1

main_hkscsFunction · 0.85

Calls 4

seekMethod · 0.45
stripMethod · 0.45
splitMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…