From: Esko Kokkonen Date: Sat, 24 Sep 2011 14:36:16 +0000 (+0300) Subject: print_versions(): Pad strings correctly when colors are used X-Git-Url: http://git.itanic.dy.fi/?p=emerge-timer;a=commitdiff_plain;h=6690d5a86453cd1c5003b46f6c7e355782c89dbf print_versions(): Pad strings correctly when colors are used Color characters aren't counted when they appear in the screen, but len() does count them, so we need a special fix for the padding to work properly in these cases. --- diff --git a/emerge-timer.py b/emerge-timer.py index 9ab7cab..7ac3f37 100755 --- a/emerge-timer.py +++ b/emerge-timer.py @@ -102,15 +102,17 @@ class package: if len(p[0]) > version_length: version_length = len(p[0]) - if len(give_time(p[1])) > time_length: - time_length = len(give_time(p[1])) + if len(give_time(p[1], True)) > time_length: + time_length = len(give_time(p[1], True)) for p in self.versions: + pad = time_length - len(give_time(p[1], True)) + print('-'*90 + "\n" + green_start + self.name + (p[0]).ljust(version_length) + - color_stop + " >>> " + (give_time(p[1])).ljust(time_length) - + " >>> " + give_date(p[2])) + color_stop + " >>> " + (give_time(p[1])) + " "*pad + + " >>> " + give_date(p[2])) print('-'*90 + "\n" + "Package " + green_start + self.name + color_stop + " emerged " +