Reimplemented explain feature
This commit is contained in:
@@ -424,3 +424,18 @@ def tokens_index(tokens, sub_tokens, skip=0):
|
||||
skip -= 1
|
||||
|
||||
raise ValueError(f"sub tokens '{sub_tokens}' not found")
|
||||
|
||||
|
||||
def as_bag(obj):
|
||||
"""
|
||||
Get the properties of an object (static and dynamic)
|
||||
:param obj:
|
||||
:return:
|
||||
"""
|
||||
if hasattr(obj, "as_bag"):
|
||||
bag = obj.as_bag()
|
||||
else:
|
||||
bag = {prop: getattr(obj, prop) for prop in dir(obj) if not prop.startswith("_")}
|
||||
|
||||
bag["self"] = obj
|
||||
return bag
|
||||
|
||||
Reference in New Issue
Block a user