MCPcopy Index your code
hub / github.com/prometheus/client_python / _split_quoted

Function _split_quoted

prometheus_client/parser.py:176–201  ·  view source on GitHub ↗

Splits on split_ch similarly to strings.split, skipping separators if they are inside quotes.

(text, separator, maxsplit=0)

Source from the content-addressed store, hash-verified

174
175
176def _split_quoted(text, separator, maxsplit=0):
177 """Splits on split_ch similarly to strings.split, skipping separators if
178 they are inside quotes.
179 """
180
181 tokens = ['']
182 x = 0
183 while x < len(text):
184 split_pos = _next_unquoted_char(text, separator, x)
185 if split_pos == -1:
186 tokens[-1] = text[x:]
187 x = len(text)
188 continue
189 # If the first character is the separator keep going. This happens when
190 # there are double whitespace characters separating symbols.
191 if split_pos == x:
192 x += 1
193 continue
194
195 if maxsplit > 0 and len(tokens) > maxsplit:
196 tokens[-1] = text[x:]
197 break
198 tokens[-1] = text[x:split_pos]
199 x = split_pos + 1
200 tokens.append('')
201 return tokens
202
203
204def _unquote_unescape(text):

Callers 2

Calls 1

_next_unquoted_charFunction · 0.85

Tested by

no test coverage detected