MCPcopy Create free account
hub / github.com/cdgriffith/Box / __getattr__

Method __getattr__

box/box.py:822–840  ·  view source on GitHub ↗
(self, item)

Source from the content-addressed store, hash-verified

820 raise BoxTypeError(str(err)) from _exception_cause(err)
821
822 def __getattr__(self, item):
823 try:
824 try:
825 value = self.__getitem__(item, _ignore_default=True)
826 except KeyError:
827 value = object.__getattribute__(self, item)
828 except AttributeError as err:
829 if item == "_box_config":
830 raise BoxError("_box_config key must exist") from _exception_cause(err)
831 if self._box_config["conversion_box"]:
832 safe_key = self._safe_attr(item)
833 if safe_key in self._box_config["__safe_keys"]:
834 return self.__getitem__(self._box_config["__safe_keys"][safe_key])
835 if self._box_config["default_box"]:
836 if item.startswith("_") and item.endswith("_"):
837 raise BoxKeyError(f"{item}: Does not exist and internal methods are never defaulted")
838 return self.__get_default(item)
839 raise BoxKeyError(str(err)) from _exception_cause(err)
840 return value
841
842 def _flush_pending_parent(self):
843 """

Callers 5

test_get_box_configMethod · 0.95
boolMethod · 0.80
intMethod · 0.80
floatMethod · 0.80
listMethod · 0.80

Calls 6

__getitem__Method · 0.95
_safe_attrMethod · 0.95
__get_defaultMethod · 0.95
BoxErrorClass · 0.90
BoxKeyErrorClass · 0.90
_exception_causeFunction · 0.85

Tested by 1

test_get_box_configMethod · 0.76