Overhaul module-related commands

This commit is contained in:
DarkPhoenix
2019-04-12 04:02:28 +03:00
parent 5579929f83
commit ad03f907fa
18 changed files with 307 additions and 373 deletions

10
utils/repr.py Normal file
View File

@@ -0,0 +1,10 @@
def makeReprStr(instance, spec=None):
arg_list = []
for field in spec or ():
if isinstance(field, str):
repr_name, attr_name = field, field
else:
repr_name, attr_name = field
attr_val = getattr(instance, attr_name, 'N/A')
arg_list.append('{}={}'.format(repr_name, attr_val))
return '<{}({})>'.format(type(instance).__name__, ', '.join(arg_list))