summaryrefslogtreecommitdiff
path: root/python/debuginfo.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/debuginfo.py')
-rw-r--r--python/debuginfo.py19
1 files changed, 18 insertions, 1 deletions
diff --git a/python/debuginfo.py b/python/debuginfo.py
index a76a8a6c..0b20ad69 100644
--- a/python/debuginfo.py
+++ b/python/debuginfo.py
@@ -19,7 +19,7 @@
# IN THE SOFTWARE.
import ctypes
-from typing import Optional, List, Iterator, Callable, Tuple
+from typing import Optional, List, Iterator, Callable, Tuple, Any
import traceback
from dataclasses import dataclass, field
@@ -78,6 +78,23 @@ class _DebugInfoParserMetaClass(type):
assert parser_ref is not None, "core.BNNewDebugInfoParserReference returned None"
return DebugInfoParser(parser_ref)
+ def __contains__(cls: '_DebugInfoParserMetaClass', name: object) -> bool:
+ if not isinstance(name, str):
+ return False
+ try:
+ cls[name]
+ return True
+ except KeyError:
+ return False
+
+ def get(cls: '_DebugInfoParserMetaClass', name: str, default: Any = None) -> Optional['DebugInfoParser']:
+ try:
+ return cls[name]
+ except KeyError:
+ if default is not None:
+ return default
+ return None
+
@staticmethod
def get_parsers_for_view(view: 'binaryview.BinaryView') -> List['DebugInfoParser']:
"""Returns a list of debug-info parsers that are valid for the provided binary view"""