Commit 84ed6035 authored by Seblu's avatar Seblu
Browse files

fix some unicode issue

parent 94ddafa8
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -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"])
+6 −6
Original line number Diff line number Diff line
@@ -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