Beispiel #1
0
    def dump_option_dicts(self, header=None, commands=None, indent=""):
        from pshout import pformat

        if commands is None:             # dump all command option dicts
            commands = self.command_options.keys()
            commands.sort()

        if header is not None:
            self.announce(indent + header)
            indent = indent + "  "

        if not commands:
            self.announce(indent + "no commands known yet")
            return

        for cmd_name in commands:
            opt_dict = self.command_options.get(cmd_name)
            if opt_dict is None:
                self.announce(indent +
                              "no option dict for '%s' command" % cmd_name)
            else:
                self.announce(indent +
                              "option dict for '%s' command:" % cmd_name)
                out = pformat(opt_dict)
                for line in out.split('\n'):
                    self.announce(indent + "  " + line)
Beispiel #2
0
 def finish(self):
     f = open(path.join(self.outdir, 'topics.py'), 'wb')
     try:
         f.write('# -*- coding: utf-8 -*-\n'.encode('utf-8'))
         f.write(('# Autogenerated by Sphinx on %s\n' % asctime()).encode('utf-8'))
         f.write(('topics = ' + pformat(self.topics) + '\n').encode('utf-8'))
     finally:
         f.close()
Beispiel #3
0
def stringify(val):
    # TODO: repr() puts everything on one line; pformat can be nicer, but
    # can lead to v.long results; this function isolates the choice
    if True:
        return repr(val)
    else:
        from pshout import pformat
        return pformat(val)