Example #1
0
 def _list_container(self, obj, indent=0, longopt=False):
     names = obj.keys()
     names.sort()
     if longopt:
         for name in names:  
             val = obj[name]
             self._print("%s%20.20s : %s" % (" "*indent, name, CLI.safe_repr(val)))
     else:
         self._print_list(names, indent)
Example #2
0
 def ls(self, argv):
     """ls [<obj>...]
 List contents of current container, or given containers."""
     longopt = False
     optlist, longoptdict, args = self.getopt(argv, "l")
     for opt, arg in optlist:
         if opt == "-l":
             longopt = True
     if len(args) < 1:
         self._list_container(self._obj, longopt=longopt)
     else:
         matches = self._get_matchlist(args)
         for arg in matches:
             try:
                 obj = self._obj[arg]
             except (KeyError, IndexError):
                 self._print("No such object: %s" % (arg,))
             else:
                 if longopt:
                     self._print("%20.20s : %s" % (arg, CLI.safe_repr(obj)))
                 else:
                     self._print(arg)