From 84ed6035fa64a52e5db3d4f0a3b1bc2687cf722f Mon Sep 17 00:00:00 2001 From: Seblu <sebastien.luttringer@smartjog.com> Date: Fri, 11 Feb 2011 18:49:53 +0100 Subject: [PATCH] fix some unicode issue --- cccli/command/list.py | 8 ++++---- cccli/tagdisplay.py | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/cccli/command/list.py b/cccli/command/list.py index 5a3d748..c405adb 100644 --- a/cccli/command/list.py +++ b/cccli/command/list.py @@ -63,7 +63,7 @@ class Command_list(OptionCommand): tags = dict() for o in objs: for t,v in o.items(): - tags[t] = max(len(self.td(t, v)), tags.get(t, len(str(t)))) + tags[t] = max(len(self.td(t, v)), tags.get(t, len(t))) # extract id size idsize = tags.pop("id") # dislay each object by line @@ -77,7 +77,7 @@ class Command_list(OptionCommand): line += "%s%s:%s%s"%(color["reset"], tagname, self.tc(tagname), - self.td(tagname, o.get(tagname, "")).ljust(tags[tagname] + 1)) + self.td(tagname, o.get(tagname, u"")).ljust(tags[tagname] + 1)) self.printer.out("%s%s"%(line, color["reset"])) def _list_table(self, objs): @@ -86,7 +86,7 @@ class Command_list(OptionCommand): tags = dict() for o in objs: for t,v in o.items(): - tags[t] = max(len(self.td(t, v)), tags.get(t, len(str(t)))) + tags[t] = max(len(self.td(t, v)), tags.get(t, len(t))) # extract id size idsize = tags.pop("id") # print id title @@ -104,5 +104,5 @@ class Command_list(OptionCommand): # print others tags for (t, v) in tags.items(): self.printer.out(self.tc(t), nl="") - self.printer.out(self.td(t, obj.get(t, "")).ljust(v) ,nl=" ") + self.printer.out(self.td(t, obj.get(t, u"")).ljust(v) ,nl=" ") self.printer.out(color["reset"]) diff --git a/cccli/tagdisplay.py b/cccli/tagdisplay.py index c87aee4..50fced8 100644 --- a/cccli/tagdisplay.py +++ b/cccli/tagdisplay.py @@ -117,7 +117,7 @@ class TagDisplay(object): p = min(math.floor(math.log10(abs(v))/3.0), len(si)) d = v / pow(10, 3*p) u = si[int(p-1)] - value = "%.1f%s"%(d, u) + value = u"%.1f%s"%(d, u) return value def type_bit(self, value): @@ -129,7 +129,7 @@ class TagDisplay(object): p = min(math.floor(math.log(abs(v), 2)/10.0), pow(2, len(si))) d = v / pow(2, 10*p) u = si[int(p-1)] - value = "%.1f%si"%(d, u) + value = u"%.1f%si"%(d, u) return value def type_second(self, value): @@ -137,12 +137,12 @@ class TagDisplay(object): if value.isdecimal(): v = long(value) if v < 60: - return "%ss"%value + return u"%ss"%value elif v < 3600: - return "%dm%ds"%(v/60, v%60) + return u"%dm%ds"%(v/60, v%60) elif v < 86400: - return "%dh%dm%ds"%(v/3600, v/60%60, v%60) + return u"%dh%dm%ds"%(v/3600, v/60%60, v%60) else: - return "%dd%dh%dm%ds"%(v/86400, v/3600%24, v/60%60, v%60) + return u"%dd%dh%dm%ds"%(v/86400, v/3600%24, v/60%60, v%60) return value -- GitLab