Better dumping

This commit is contained in:
Elliot Nunn 2018-10-08 09:46:19 +08:00
parent eb847a97cd
commit 5dff862548

View File

@ -51,6 +51,18 @@ class AbstractFolder(collections.MutableMapping):
the_dict = {self._prefdict[k]: v for (k, v) in self._maindict.items()} the_dict = {self._prefdict[k]: v for (k, v) in self._maindict.items()}
return repr(the_dict) return repr(the_dict)
def __str__(self):
lines = []
for k, v in self.items():
v = str(v)
if '\n' in v:
lines.append(k + ':')
for l in v.split('\n'):
lines.append(' ' + l)
else:
lines.append(k + ': ' + v)
return '\n'.join(lines)
def iter_paths(self): def iter_paths(self):
for name, child in self.items(): for name, child in self.items():
yield ((name,), child) yield ((name,), child)