MCPcopy Create free account
hub / github.com/MotrixLab/AiOS / __check_key__

Method __check_key__

detrsmpl/data/data_structures/human_data.py:753–791  ·  view source on GitHub ↗

Check whether the key matches definition in HumanData.SUPPORTED_KEYS. Args: key (Any): Key in HumanData. Returns: _KeyCheck: PASS, WARN or ERROR. Raises: KeyError: self.get_key_stri

(self, key: Any)

Source from the content-addressed store, hash-verified

751 self.pop(key)
752
753 def __check_key__(self, key: Any) -> _KeyCheck:
754 """Check whether the key matches definition in
755 HumanData.SUPPORTED_KEYS.
756
757 Args:
758 key (Any):
759 Key in HumanData.
760
761 Returns:
762 _KeyCheck:
763 PASS, WARN or ERROR.
764
765 Raises:
766 KeyError:
767 self.get_key_strict() is True and
768 key cannot be found in
769 HumanData.SUPPORTED_KEYS.
770 """
771 ret_key_check = _KeyCheck.PASS
772 if self.get_key_strict():
773 if key not in self.__class__.SUPPORTED_KEYS:
774 ret_key_check = _KeyCheck.ERROR
775 else:
776 if key not in self.__class__.SUPPORTED_KEYS and \
777 key not in self.__class__.WARNED_KEYS:
778 # log warning message at the first time
779 ret_key_check = _KeyCheck.WARN
780 self.__class__.WARNED_KEYS.append(key)
781 if ret_key_check == _KeyCheck.ERROR:
782 raise KeyError(self.__class__.__get_key_error_msg__(key))
783 elif ret_key_check == _KeyCheck.WARN:
784 class_logger = self.__class__.logger
785 if class_logger == 'silent':
786 pass
787 else:
788 print_log(msg=self.__class__.__get_key_warn_msg__(key),
789 logger=class_logger,
790 level=logging.WARN)
791 return ret_key_check
792
793 def __check_value__(self, key: Any, val: Any) -> bool:
794 """Check whether the value matches definition in

Callers 2

__setitem__Method · 0.95
set_raw_valueMethod · 0.95

Calls 3

get_key_strictMethod · 0.95
__get_key_error_msg__Method · 0.80
__get_key_warn_msg__Method · 0.80

Tested by

no test coverage detected