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

Method __getattr__

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

Source from the content-addressed store, hash-verified

639 raise BoxTypeError(str(err)) from _exception_cause(err)
640
641 def __getattr__(self, item):
642 try:
643 try:
644 value = self.__getitem__(item, _ignore_default=True)
645 except KeyError:
646 value = object.__getattribute__(self, item)
647 except AttributeError as err:
648 if item == "__getstate__":
649 raise BoxKeyError(item) from _exception_cause(err)
650 if item == "_box_config":
651 raise BoxError("_box_config key must exist") from _exception_cause(err)
652 if self._box_config["conversion_box"]:
653 safe_key = self._safe_attr(item)
654 if safe_key in self._box_config["__safe_keys"]:
655 return self.__getitem__(self._box_config["__safe_keys"][safe_key])
656 if self._box_config["default_box"]:
657 if item.startswith("_") and item.endswith("_"):
658 raise BoxKeyError(f"{item}: Does not exist and internal methods are never defaulted")
659 return self.__get_default(item, attr=True)
660 raise BoxKeyError(str(err)) from _exception_cause(err)
661 return value
662
663 def __setitem__(self, key, value):
664 if key != "_box_config" and self._box_config["frozen_box"] and self._box_config["__created"]:

Callers 1

test_get_box_configMethod · 0.95

Calls 6

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

Tested by 1

test_get_box_configMethod · 0.76