MCPcopy
hub / github.com/django/django / __getitem__

Method __getitem__

django/utils/datastructures.py:274–285  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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
288class CaseInsensitiveMapping(Mapping):

Callers 2

__getitem__Method · 0.45
_getlistMethod · 0.45

Calls 1

funcMethod · 0.45

Tested by

no test coverage detected