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

Function _next_unquoted_char

prometheus_client/parser.py:140–156  ·  view source on GitHub ↗

Return position of next unquoted character in tuple, or -1 if not found. It is always assumed that the first character being checked is not already inside quotes.

(text: str, chs: Optional[str], startidx: int = 0)

Source from the content-addressed store, hash-verified

138
139
140def _next_unquoted_char(text: str, chs: Optional[str], startidx: int = 0) -> int:
141 """Return position of next unquoted character in tuple, or -1 if not found.
142
143 It is always assumed that the first character being checked is not already
144 inside quotes.
145 """
146 in_quotes = False
147 if chs is None:
148 chs = string.whitespace
149
150 for i, c in enumerate(text[startidx:]):
151 if c == '"' and not _is_character_escaped(text, startidx + i):
152 in_quotes = not in_quotes
153 if not in_quotes:
154 if c in chs:
155 return startidx + i
156 return -1
157
158
159def _last_unquoted_char(text: str, chs: Optional[str]) -> int:

Callers 6

_next_termFunction · 0.85
_split_quotedFunction · 0.85
_parse_sampleFunction · 0.85
_parse_sampleFunction · 0.85
_parse_remaining_textFunction · 0.85
_parse_nh_sampleFunction · 0.85

Calls 1

_is_character_escapedFunction · 0.70

Tested by

no test coverage detected