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.
| 104 | |
| 105 | |
| 106 | class _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 | |
| 137 | def inspect_format_method(callable): |
no outgoing calls
no test coverage detected
searching dependent graphs…