def __repr__(self):
'''Display all the fields within the specified structure.'''
result = []
mn, ms = 0, 0
for i in xrange(len(self)):
m = self[i]
name,t,ofs,size,comment = m.name,m.type,m.offset,m.size,m.comment
result.append((i,name,t,ofs,size,comment))
mn = max((mn,len(name)))
ms = max((ms,len("{:x}".format(size))))
mi = len(str(len(self)))
mo = max(map(len,map("{:x}".format, (self.baseoffset,self.baseoffset+self.owner.size))))
return "{!r}\n{:s}".format(self.owner, '\n'.join("[{:{:d}d}] {:>{:d}x}:+{:<{:d}x} {:<{:d}s} {!r} {:s}".format(i,mi,o,mo,s,ms,"'{:s}'".format(n),mn+2,t," // {:s}".format(c) if c else '') for i,n,t,o,s,c in result))
评论列表
文章目录