Respond to feedback

This commit is contained in:
Abogical 2016-11-14 11:43:46 +02:00
parent 1362d2e90f
commit 3232769ffc
1 changed files with 4 additions and 4 deletions

View File

@ -1193,11 +1193,11 @@ def yes(msg=None, false_msg=None, true_msg=None, default_msg=None,
def ellipsis_truncate(msg, space): def ellipsis_truncate(msg, space):
from .platform import swidth
""" """
shorten a long string by adding ellipsis between it and return it, example: shorten a long string by adding ellipsis between it and return it, example:
this_is_a_very_long_string -------> this_is..._string this_is_a_very_long_string -------> this_is..._string
""" """
from .platform import swidth
ellipsis_width = swidth('...') ellipsis_width = swidth('...')
msg_width = swidth(msg) msg_width = swidth(msg)
if space < ellipsis_width + msg_width: if space < ellipsis_width + msg_width:
@ -1253,11 +1253,11 @@ class ProgressIndicatorPercent:
self.trigger_at += self.step self.trigger_at += self.step
return pct return pct
def show(self, current=None, increase=1, info=[]): def show(self, current=None, increase=1, info=None):
pct = self.progress(current, increase) pct = self.progress(current, increase)
if pct is not None: if pct is not None:
# truncate the last argument, if space is available # truncate the last argument, if no space is available
if info != []: if info is not None:
msg = self.msg % tuple([pct] + info[:-1] + ['']) msg = self.msg % tuple([pct] + info[:-1] + [''])
space = get_terminal_size()[0] - len(msg) space = get_terminal_size()[0] - len(msg)
if space < 8: if space < 8: