Reimplemented explain feature

This commit is contained in:
2020-06-04 18:43:15 +02:00
parent c498b394e3
commit d7573f095f
27 changed files with 1673 additions and 1161 deletions
+15
View File
@@ -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