MCPcopy Index your code
hub / github.com/mitmproxy/mitmproxy / tokenize

Function tokenize

mitmproxy/contentviews/_view_xml_html.py:104–130  ·  view source on GitHub ↗
(data: str)

Source from the content-addressed store, hash-verified

102
103
104def tokenize(data: str) -> Iterable[Token]:
105 token: Token = Text("")
106
107 i = 0
108
109 def readuntil(char, start, include=1):
110 nonlocal i
111 end = data.find(char, start)
112 if end == -1:
113 end = len(data)
114 ret = data[i : end + include]
115 i = end + include
116 return ret
117
118 while i < len(data):
119 if isinstance(token, Text):
120 token.data = readuntil("<", i, 0)
121 if token.text:
122 yield token
123 token = Tag("")
124 elif isinstance(token, Tag):
125 token.data += readuntil(">", i, 1)
126 if token.done:
127 yield token
128 token = Text("")
129 if token.data.strip():
130 yield token
131
132
133def indent_text(data: str, prefix: str) -> str:

Callers 2

test_simpleFunction · 0.90
prettifyMethod · 0.70

Calls 3

TextClass · 0.85
readuntilFunction · 0.85
TagClass · 0.85

Tested by 1

test_simpleFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…