This commit is contained in:
+6
-5
@@ -17,16 +17,17 @@ def stringify(obj, indent=0):
|
||||
elif isinstance(obj, (int, float, str, bool)):
|
||||
return str(obj)
|
||||
elif isinstance(obj, list):
|
||||
return '\n'.join(f"{space} {stringify(e, indent + 1)}" for e in obj)
|
||||
return '\n'.join(f"{space}- {stringify(e, indent + 1)}" for e in obj)
|
||||
elif isinstance(obj, dict):
|
||||
return '\n'.join(f"{space}{k}: {stringify(v, indent + 1)}" for k, v in obj.items())
|
||||
elif hasattr(obj, '__str__'):
|
||||
elif isinstance(obj, object) and str(obj).startswith("<object object at"):
|
||||
return "<opaque object>"
|
||||
else:
|
||||
try:
|
||||
return str(obj)
|
||||
except:
|
||||
return repr(obj)
|
||||
else:
|
||||
return repr(obj)
|
||||
return "<unstringifiable>"
|
||||
|
||||
|
||||
|
||||
def normalize_nodeid(nodeid):
|
||||
|
||||
Reference in New Issue
Block a user