Better str(File)

This commit is contained in:
Elliot Nunn 2018-10-14 09:21:04 +08:00
parent ac4bedcf53
commit 925fd13cd3

View File

@ -90,7 +90,9 @@ class File:
self.data = bytearray()
def __str__(self):
return 'File %r/%r data=%db rsrc=%db' % (self.type, self.creator, len(self.data), len(self.rsrc))
typestr, creatorstr = (x.decode('mac_roman') for x in (self.type, self.creator))
dstr, rstr = (repr(bytes(x)) if 1 <= len(x) <= 32 else '%db' % len(x) for x in (self.data, self.rsrc))
return '[%s/%s] data=%s rsrc=%s' % (typestr, creatorstr, dstr, rstr)
class Volume(directory.AbstractFolder):