Skip to content

Commit

Permalink
Handle UTF-8 characters (like Umlauts) in git-pw
Browse files Browse the repository at this point in the history
v2: Fixup code to be under 79 chars (PEP8 test, Damien)
  • Loading branch information
asdil12 authored and Damien Lespiau committed Mar 16, 2016
1 parent 532baa9 commit 162df88
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions git-pw/git-pw
Original file line number Diff line number Diff line change
Expand Up @@ -409,8 +409,11 @@ class Table(object):
layout[key]['ellipsis'] = True
continue
for item in items:
layout[key]['width'] = max(layout[key]['width'],
len(str(item[key])))
if isinstance(item[key], int):
it = str(item[key])
else:
it = item[key]
layout[key]['width'] = max(layout[key]['width'], len(it))

# width of the table
width = 0
Expand Down Expand Up @@ -485,7 +488,7 @@ class Table(object):
for item in items:
for key, _ in columns.iteritems():
fmt = layout[key]['format']
sys.stdout.write(fmt.format(item[key]))
sys.stdout.write(fmt.decode().format(item[key]))
sys.stdout.write("\n")


Expand Down

0 comments on commit 162df88

Please sign in to comment.