MCPcopy Index your code
hub / github.com/nodejs/node / _MagicFormatMapping

Class _MagicFormatMapping

tools/inspector_protocol/jinja2/sandbox.py:106–134  ·  view source on GitHub ↗

This class implements a dummy wrapper to fix a bug in the Python standard library for string formatting. See https://bugs.python.org/issue13598 for information about why this is necessary.

Source from the content-addressed store, hash-verified

104
105
106class _MagicFormatMapping(Mapping):
107 """This class implements a dummy wrapper to fix a bug in the Python
108 standard library for string formatting.
109
110 See https://bugs.python.org/issue13598 for information about why
111 this is necessary.
112 """
113
114 def __init__(self, args, kwargs):
115 self._args = args
116 self._kwargs = kwargs
117 self._last_index = 0
118
119 def __getitem__(self, key):
120 if key == '':
121 idx = self._last_index
122 self._last_index += 1
123 try:
124 return self._args[idx]
125 except LookupError:
126 pass
127 key = str(idx)
128 return self._kwargs[key]
129
130 def __iter__(self):
131 return iter(self._kwargs)
132
133 def __len__(self):
134 return len(self._kwargs)
135
136
137def inspect_format_method(callable):

Callers 1

format_stringMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…