MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / create_dict_rule

Function create_dict_rule

tools/python-3.11.9-amd64/Lib/tomllib/_parser.py:284–299  ·  view source on GitHub ↗
(src: str, pos: Pos, out: Output)

Source from the content-addressed store, hash-verified

282
283
284def create_dict_rule(src: str, pos: Pos, out: Output) -> tuple[Pos, Key]:
285 pos += 1 # Skip "["
286 pos = skip_chars(src, pos, TOML_WS)
287 pos, key = parse_key(src, pos)
288
289 if out.flags.is_(key, Flags.EXPLICIT_NEST) or out.flags.is_(key, Flags.FROZEN):
290 raise suffixed_err(src, pos, f"Cannot declare {key} twice")
291 out.flags.set(key, Flags.EXPLICIT_NEST, recursive=False)
292 try:
293 out.data.get_or_create_nest(key)
294 except KeyError:
295 raise suffixed_err(src, pos, "Cannot overwrite a value") from None
296
297 if not src.startswith("]", pos):
298 raise suffixed_err(src, pos, "Expected ']' at the end of a table declaration")
299 return pos + 1, key
300
301
302def create_list_rule(src: str, pos: Pos, out: Output) -> tuple[Pos, Key]:

Callers 1

loadsFunction · 0.70

Calls 7

startswithMethod · 0.80
skip_charsFunction · 0.70
parse_keyFunction · 0.70
suffixed_errFunction · 0.70
is_Method · 0.45
setMethod · 0.45
get_or_create_nestMethod · 0.45

Tested by

no test coverage detected