MCPcopy Create free account
hub / github.com/psf/black / make_width_table

Function make_width_table

scripts/make_width_table.py:25–46  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

23
24
25def make_width_table() -> Iterable[Tuple[int, int, int]]:
26 start_codepoint = -1
27 end_codepoint = -1
28 range_width = -2
29 for codepoint in range(0, sys.maxunicode + 1):
30 width = wcwidth.wcwidth(chr(codepoint))
31 if width <= 1:
32 # Ignore narrow characters along with zero-width characters so that
33 # they are treated as single-width. Note that treating zero-width
34 # characters as single-width is consistent with the heuristics built
35 # on top of str.isascii() in the str_width() function in strings.py.
36 continue
37 if start_codepoint < 0:
38 start_codepoint = codepoint
39 range_width = width
40 elif width != range_width or codepoint != end_codepoint + 1:
41 yield (start_codepoint, end_codepoint, range_width)
42 start_codepoint = codepoint
43 range_width = width
44 end_codepoint = codepoint
45 if start_codepoint >= 0:
46 yield (start_codepoint, end_codepoint, range_width)
47
48
49def main() -> None:

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected