(self, cmd)
show: Show the current values for various settings.
show: Show the current values for various settings.
show : Show the current values for various settings .
def command_show(self, cmd):
        """show: Show the current values for various settings."""
        if len(cmd) > 1:
            raise self.Error("show takes at most one parameter")
        if len(cmd):
            what = cmd[0]
            if what not in self._shows:
                raise self.Error("Unknown show: '%s'" % (what, ))
        else:
            what = None

        outs = []
        for i in self._shows:
            k = i
            if what and i != what:
                continue
            # boolean settings
            if i in ("echo", "headers", "exceptions"):
                if i == "headers": i = "header"
                v = "off"
                if getattr(self, i):
                    v = "on"
            elif i == "explain":
                # we cheat by looking at truncate setting!
                v = "on"
                if self.truncate:
                    v = "off"
            elif i in ("nullvalue", "separator"):
                v = self._fmt_c_string(getattr(self, i))
            elif i == "mode":
                if not self._output_modes:
                    self._cache_output_modes()
                for v in self._output_modes:
                    if self.output == getattr(self, "output_" + v):
                        break
                else:
                    assert False, "Bug: didn't find output mode"
            elif i == "output":
                if self.stdout is self._original_stdout:
                    v = "stdout"
                else:
                    v = getattr(self.stdout, "name", "<unknown stdout>")
            elif i == "width":
                v = " ".join(["%d" % (i, ) for i in self.widths])
            elif i == "encoding":
                v = self.encoding[0]
                if self.encoding[1]:
                    v += " (Errors " + self.encoding[1] + ")"
            else:
                assert False, "Bug: unknown show handling"
            outs.append((k, v))

        # find width of k column
        l = 0
        for k, v in outs:
            if len(k) > l:
                l = len(k)

        for k, v in outs:
            self.write(self.stderr, "%*.*s: %s\n" % (l, l, k, v))
def command_show ( self , cmd ) : if len ( cmd ) > 1 : raise self . Error ( "show takes at most one parameter" ) if len ( cmd ) : what = cmd [ 0 ] if what not in self . _shows : raise self . Error ( "Unknown show: '%s'" % ( what , ) ) else : what = None outs = [ ] for i in self . _shows : k = i if what and i != what : continue # boolean settings if i in ( "echo" , "headers" , "exceptions" ) : if i == "headers" : i = "header" v = "off" if getattr ( self , i ) : v = "on" elif i == "explain" : # we cheat by looking at truncate setting! v = "on" if self . truncate : v = "off" elif i in ( "nullvalue" , "separator" ) : v = self . _fmt_c_string ( getattr ( self , i ) ) elif i == "mode" : if not self . _output_modes : self . _cache_output_modes ( ) for v in self . _output_modes : if self . output == getattr ( self , "output_" + v ) : break else : assert False , "Bug: didn't find output mode" elif i == "output" : if self . stdout is self . _original_stdout : v = "stdout" else : v = getattr ( self . stdout , "name" , "<unknown stdout>" ) elif i == "width" : v = " " . join ( [ "%d" % ( i , ) for i in self . widths ] ) elif i == "encoding" : v = self . encoding [ 0 ] if self . encoding [ 1 ] : v += " (Errors " + self . encoding [ 1 ] + ")" else : assert False , "Bug: unknown show handling" outs . append ( ( k , v ) ) # find width of k column l = 0 for k , v in outs : if len ( k ) > l : l = len ( k ) for k , v in outs : self . write ( self . stderr , "%*.*s: %s\n" % ( l , l , k , v ) )