trying table
This commit is contained in:
parent
5945a56f2a
commit
733458f375
@ -9,14 +9,41 @@ def table_formatter(tree_diff):
|
|||||||
m = max([(len(item['name']) + len(item['rel_path'])) for item in v ])
|
m = max([(len(item['name']) + len(item['rel_path'])) for item in v ])
|
||||||
mlen.append(m)
|
mlen.append(m)
|
||||||
# name and relpath of node
|
# name and relpath of node
|
||||||
first_column_length = max(mlen) + 2
|
column_separator = '\uFF5C'
|
||||||
second_column_length = len('Local') + 5
|
padding_right = 5
|
||||||
third_column_length = len('Remote') + 5
|
hflen = max(mlen) + padding_right
|
||||||
|
hsclen = 11 + padding_right
|
||||||
|
htclen = 11 + padding_right
|
||||||
|
|
||||||
head = "{0:>{1}}".format("Node", first_column_length)
|
htexts = ['Node', 'Local', 'Remote']
|
||||||
head += "{0:>{1}}".format("Local", second_column_length)
|
hlens = [hflen, hsclen, htclen]
|
||||||
head += "{0:>{1}}".format("Remote", third_column_length)
|
|
||||||
print(head)
|
head_str = ''
|
||||||
|
for thead_text, thead_len, align in zip(htexts, hlens, ['^']*len(hlens)):
|
||||||
|
head_str += "{0:{align}{flen}}".format(thead_text, align=align, flen=thead_len)
|
||||||
|
head_str += column_separator
|
||||||
|
head_str += '\n'
|
||||||
|
|
||||||
|
sep_str = ''
|
||||||
|
for head_column_length in [hflen, hsclen, htclen]:
|
||||||
|
sep_str += '{0:{fill}<{flen}}'.format('',fill='\u2015', flen=head_column_length)
|
||||||
|
sep_str += column_separator
|
||||||
|
sep_str += '\n'
|
||||||
|
|
||||||
|
# head_str += (len(column_separator)*len(hlens) + sum(hlens)) * '\u2015' + '\n'
|
||||||
|
head_str += sep_str
|
||||||
|
|
||||||
|
rows = ''
|
||||||
|
row = ''
|
||||||
|
trow_texts = ['casual', 'M', 'X']
|
||||||
|
for trow_text,flen in zip(trow_texts, hlens):
|
||||||
|
row += "{0:{flen}}".format(trow_text, flen=flen)
|
||||||
|
row += column_separator
|
||||||
|
|
||||||
|
rows += row
|
||||||
|
|
||||||
|
|
||||||
|
print(head_str+rows)
|
||||||
|
|
||||||
|
|
||||||
def human_tree_diff():
|
def human_tree_diff():
|
||||||
|
Loading…
x
Reference in New Issue
Block a user