Skip to content

Commit

Permalink
gpo: Fix line length calculation for byte strings (bug 1598)
Browse files Browse the repository at this point in the history
gpo incorrectly calculates the length of podcasts containing non-ASCII
characters (e.g. Russian ones), which results in the "[DONE]" label
being closer to the message and not aligned with other "[DONE]" labels.
This patch fixes it by converting byte strings to unicode before
calculating the string length, resulting in properly aligned output.
  • Loading branch information
pluton8 authored and thp committed May 20, 2012
1 parent 08c5bd1 commit 9dd817d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion bin/gpo
Expand Up @@ -78,6 +78,8 @@ if os.path.exists(src_dir) and os.path.exists(data_dir) and \
import gpodder
_ = gpodder.gettext

from gpodder import util

# Use only the gPodder API here, so this serves both as an example
# and as a motivation to provide all functionality in the API :)
from gpodder import api
Expand All @@ -99,7 +101,7 @@ class gPodderCli(object):
self._current_action = ''

def _start_action(self, msg, *args):
line = msg % args
line = util.convert_bytes(msg % args)
if len(line) > self.COLUMNS-7:
line = line[:self.COLUMNS-7-3] + '...'
else:
Expand Down

0 comments on commit 9dd817d

Please sign in to comment.