Loading cccli/command/list.py +17 −4 Original line number Diff line number Diff line Loading @@ -9,6 +9,7 @@ from cccli.exception import * from sjrpc.core.exceptions import * from cccli.printer import Printer, color from cccli.command.command import TqlCommand import math class Command_list(TqlCommand): '''List objects''' Loading @@ -35,7 +36,7 @@ class Command_list(TqlCommand): elif self.options.table: self.list_table(objs) else: self.print_objects(objs) self.print_objects(objs, index=self.options.index) def list_align(self, objs): '''Listing line aligned''' Loading @@ -47,8 +48,13 @@ class Command_list(TqlCommand): # build initial print order order = [ t for t in objs.get("order", []) if t in tags ] order.extend(sorted(set(tags.keys()) - set(order))) # compute index width indexw = int(math.log10(len(objs["objects"]))) # dislay each object by line for o in objs["objects"]: for (i,o) in enumerate(objs["objects"]): if self.options.index: line = ("[%d]"%i).ljust(indexw + 4) else: line = "" for t in order: line += "%s%s:%s%s "%(self.tdtc(t), Loading @@ -67,14 +73,21 @@ class Command_list(TqlCommand): # build initial print order order = [ t for t in objs.get("order", []) if t in tags ] order.extend(sorted(set(tags.keys()) - set(order))) if self.options.index: # compute index width indexw = max(int(math.log10(len(objs["objects"]))+1), len("index ")) # print index title self.printer.out("index ", nl="") # print tag title in order for t in order: self.printer.out(self.tdtc(t), nl="") self.printer.out(t.ljust(tags[t]), nl=" ") self.printer.out(color["reset"]) # print tags in order for o in objs["objects"]: for (i,o) in enumerate(objs["objects"]): for t in order: if self.options.index: self.printer.out(("%d "%i).ljust(indexw), nl="") self.printer.out(self.tdc(t), nl="") self.printer.out(self.tdr(t, o.get(t, u"")).ljust(tags[t]) ,nl=" ") self.printer.out(color["reset"]) Loading
cccli/command/list.py +17 −4 Original line number Diff line number Diff line Loading @@ -9,6 +9,7 @@ from cccli.exception import * from sjrpc.core.exceptions import * from cccli.printer import Printer, color from cccli.command.command import TqlCommand import math class Command_list(TqlCommand): '''List objects''' Loading @@ -35,7 +36,7 @@ class Command_list(TqlCommand): elif self.options.table: self.list_table(objs) else: self.print_objects(objs) self.print_objects(objs, index=self.options.index) def list_align(self, objs): '''Listing line aligned''' Loading @@ -47,8 +48,13 @@ class Command_list(TqlCommand): # build initial print order order = [ t for t in objs.get("order", []) if t in tags ] order.extend(sorted(set(tags.keys()) - set(order))) # compute index width indexw = int(math.log10(len(objs["objects"]))) # dislay each object by line for o in objs["objects"]: for (i,o) in enumerate(objs["objects"]): if self.options.index: line = ("[%d]"%i).ljust(indexw + 4) else: line = "" for t in order: line += "%s%s:%s%s "%(self.tdtc(t), Loading @@ -67,14 +73,21 @@ class Command_list(TqlCommand): # build initial print order order = [ t for t in objs.get("order", []) if t in tags ] order.extend(sorted(set(tags.keys()) - set(order))) if self.options.index: # compute index width indexw = max(int(math.log10(len(objs["objects"]))+1), len("index ")) # print index title self.printer.out("index ", nl="") # print tag title in order for t in order: self.printer.out(self.tdtc(t), nl="") self.printer.out(t.ljust(tags[t]), nl=" ") self.printer.out(color["reset"]) # print tags in order for o in objs["objects"]: for (i,o) in enumerate(objs["objects"]): for t in order: if self.options.index: self.printer.out(("%d "%i).ljust(indexw), nl="") self.printer.out(self.tdc(t), nl="") self.printer.out(self.tdr(t, o.get(t, u"")).ljust(tags[t]) ,nl=" ") self.printer.out(color["reset"])