Simply __str__ function
This commit is contained in:
parent
90be4421c5
commit
f0608c7212
@ -377,27 +377,21 @@ class Relation (object):
|
|||||||
return len(self.content)
|
return len(self.content)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
m_len = [] # Maximum lenght string
|
m_len = [len(i) for i in self.header] # Maximum lenght string
|
||||||
for f in self.header:
|
|
||||||
m_len.append(len(f))
|
|
||||||
|
|
||||||
for f in self.content:
|
for f in self.content:
|
||||||
col = 0
|
for col,i in enumerate(f):
|
||||||
for i in f:
|
|
||||||
if len(i) > m_len[col]:
|
if len(i) > m_len[col]:
|
||||||
m_len[col] = len(i)
|
m_len[col] = len(i)
|
||||||
col += 1
|
|
||||||
|
|
||||||
res = ""
|
res = ""
|
||||||
for f, attr in enumerate(self.header):
|
for f, attr in enumerate(self.header):
|
||||||
res += "%s" % (attr.ljust(2 + m_len[f]))
|
res += "%s" % (attr.ljust(2 + m_len[f]))
|
||||||
|
|
||||||
for r in self.content:
|
for r in self.content:
|
||||||
col = 0
|
|
||||||
res += "\n"
|
res += "\n"
|
||||||
for i in r:
|
for col,i in enumerate(r):
|
||||||
res += "%s" % (i.ljust(2 + m_len[col]))
|
res += "%s" % (i.ljust(2 + m_len[col]))
|
||||||
col += 1
|
|
||||||
|
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user