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

Method buildmap

Tools/unicode/genmap_support.py:118–141  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

116 self.printmap()
117
118 def buildmap(self):
119 for c1 in range(0, 256):
120 if c1 not in self.encode_map:
121 continue
122 c2map = self.encode_map[c1]
123 rc2values = [k for k in c2map.keys()]
124 rc2values.sort()
125 if not rc2values:
126 continue
127
128 c2map[self.prefix] = True
129 c2map['min'] = rc2values[0]
130 c2map['max'] = rc2values[-1]
131 c2map['midx'] = len(self.filler)
132
133 for v in range(rc2values[0], rc2values[-1] + 1):
134 if v not in c2map:
135 self.write_nochar()
136 elif isinstance(c2map[v], int):
137 self.write_char(c2map[v])
138 elif isinstance(c2map[v], tuple):
139 self.write_multic(c2map[v])
140 else:
141 raise ValueError
142
143 def write_nochar(self):
144 self.filler.write('N,')

Callers 1

generateMethod · 0.95

Calls 5

write_nocharMethod · 0.95
write_charMethod · 0.95
write_multicMethod · 0.95
keysMethod · 0.45
sortMethod · 0.45

Tested by

no test coverage detected