Retrieve the real value after stripping the prefix string (if present). If the prefix is present, pass the value through self.func before returning, otherwise return the raw value.
(self, key)
| 272 | self.prefix = prefix |
| 273 | |
| 274 | def __getitem__(self, key): |
| 275 | """ |
| 276 | Retrieve the real value after stripping the prefix string (if |
| 277 | present). If the prefix is present, pass the value through self.func |
| 278 | before returning, otherwise return the raw value. |
| 279 | """ |
| 280 | use_func = key.startswith(self.prefix) |
| 281 | key = key.removeprefix(self.prefix) |
| 282 | value = super().__getitem__(key) |
| 283 | if use_func: |
| 284 | return self.func(value) |
| 285 | return value |
| 286 | |
| 287 | |
| 288 | class CaseInsensitiveMapping(Mapping): |
no test coverage detected