MCPcopy Create free account
hub / github.com/sqlalchemy/sqlalchemy / prefix_anon_map

Class prefix_anon_map

lib/sqlalchemy/sql/_py_util.py:22–40  ·  view source on GitHub ↗

A map that creates new keys for missing key access. Considers keys of the form " " to produce new symbols " _ ", where "index" is an incrementing integer corresponding to . Inlines the approach taken by :class:`sqlalchemy.util.PopulateDict` which i

Source from the content-addressed store, hash-verified

20
21
22class prefix_anon_map(Dict[str, str]):
23 """A map that creates new keys for missing key access.
24
25 Considers keys of the form "<ident> <name>" to produce
26 new symbols "<name>_<index>", where "index" is an incrementing integer
27 corresponding to <name>.
28
29 Inlines the approach taken by :class:`sqlalchemy.util.PopulateDict` which
30 is otherwise usually used for this type of operation.
31
32 """
33
34 def __missing__(self, key: str) -> str:
35 ident, derived = key.split(" ", 1)
36 anonymous_counter = self.get(derived, 1)
37 self[derived] = anonymous_counter + 1 # type: ignore
38 value = f"{derived}_{anonymous_counter}"
39 self[key] = value
40 return value
41
42
43class cache_anon_map(

Callers 4

_generate_param_dictMethod · 0.85
__init__Method · 0.85

Calls

no outgoing calls