def printenv(self, argv): """printenv [name ...] Shows the shell environment that processes will run with. """ if len(argv) == 1: names = list(self._environ.keys()) names.sort() ms = functools.reduce(max, map(len, names)) for name in names: value = self._environ[name] self._print("{:{maxsize}s} = {}".format(name, safe_repr(value), maxsize=ms)) else: s = [] for name in argv[1:]: try: s.append("{} = {}".format(name, safe_repr(self._environ[name]))) except KeyError: pass self._print("\n".join(s))
def show(self, argv): """show Display list contents.""" for i, obj in enumerate(self._obj): self._print("%5.5s: %s" % (i, safe_repr(obj)))
def items(self, argv): """items Show mapping items.""" for name, val in self._obj.items(): self._print("%25.25r: %s" % (name, safe_repr(val)))