summaryrefslogtreecommitdiff
path: root/python/binaryview.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/binaryview.py')
-rw-r--r--python/binaryview.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/python/binaryview.py b/python/binaryview.py
index 5c49a697..d0d20405 100644
--- a/python/binaryview.py
+++ b/python/binaryview.py
@@ -1448,6 +1448,23 @@ class _BinaryViewTypeMetaclass(type):
raise KeyError(f"'{value}' is not a valid view type")
return BinaryViewType(view_type)
+ def __contains__(cls: '_BinaryViewTypeMetaclass', name: object) -> bool:
+ if not isinstance(name, str):
+ return False
+ try:
+ cls[name]
+ return True
+ except KeyError:
+ return False
+
+ def get(cls: '_BinaryViewTypeMetaclass', name: str, default: Any = None) -> Optional['BinaryViewType']:
+ try:
+ return cls[name]
+ except KeyError:
+ if default is not None:
+ return default
+ return None
+
class BinaryViewType(metaclass=_BinaryViewTypeMetaclass):
"""