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

Function wlen

Lib/_pyrepl/utils.py:78–85  ·  view source on GitHub ↗
(s: str)

Source from the content-addressed store, hash-verified

76
77
78def wlen(s: str) -> int:
79 if len(s) == 1 and s != "\x1a":
80 return str_width(s)
81 length = sum(str_width(i) for i in s)
82 # remove lengths of any escape sequences
83 sequence = ANSI_ESCAPE_SEQUENCE.findall(s)
84 ctrl_z_cnt = s.count("\x1a")
85 return length - sum(len(i) for i in sequence) + ctrl_z_cnt
86
87
88def unbracket(s: str, including_content: bool = False) -> str:

Callers 4

test_wlenMethod · 0.90
process_promptMethod · 0.85
__write_changed_lineMethod · 0.85
__write_changed_lineMethod · 0.85

Calls 3

str_widthFunction · 0.85
findallMethod · 0.45
countMethod · 0.45

Tested by 1

test_wlenMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…