summaryrefslogtreecommitdiff
path: root/python/lineformatter.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/lineformatter.py')
-rw-r--r--python/lineformatter.py19
1 files changed, 18 insertions, 1 deletions
diff --git a/python/lineformatter.py b/python/lineformatter.py
index 7f74572b..f63526f1 100644
--- a/python/lineformatter.py
+++ b/python/lineformatter.py
@@ -21,7 +21,7 @@
import ctypes
import traceback
from dataclasses import dataclass
-from typing import List, Optional, Union
+from typing import List, Optional, Union, Any
# Binary Ninja components
import binaryninja
@@ -118,6 +118,23 @@ class _LineFormatterMetaClass(type):
raise KeyError("'%s' is not a valid formatter" % str(value))
return CoreLineFormatter(handle=lang)
+ def __contains__(cls: '_LineFormatterMetaClass', name: object) -> bool:
+ if not isinstance(name, str):
+ return False
+ try:
+ cls[name]
+ return True
+ except KeyError:
+ return False
+
+ def get(cls: '_LineFormatterMetaClass', name: str, default: Any = None) -> Optional['LineFormatter']:
+ try:
+ return cls[name]
+ except KeyError:
+ if default is not None:
+ return default
+ return None
+
class LineFormatter(metaclass=_LineFormatterMetaClass):
"""