def main(argv=None): if argv is None: argv = sys.argv parser = argparse.ArgumentParser( description='Generate color schemes in different formats') parser.add_argument('--help-style', nargs=0, action=_ListStyles, help='Show available Pygments styles and exit') parser.add_argument('--help-format', nargs=0, action=_ListFormats, help='Show available applications and exit') parser.add_argument('format', metavar='format', choices=FORMAT_NAMES, help='Target format') group = parser.add_mutually_exclusive_group(required=True) group.add_argument('-S', dest='pygments_style', metavar='STYLE', choices=STYLE_NAMES, help='Use existing Pygments style') group.add_argument('-f', dest='style', metavar='FILE', type=argparse.FileType('r'), help='Use style definition file') args = parser.parse_args() if args.pygments_style: style = create_style_from_pygments(args.pygments_style) elif args.style: reader = FORMATS['pygoutconfig']() style = reader.read(args.style) writer = FORMATS[args.format]() writer.write(sys.stdout, style)
def test(style): pygments_style = get_style_by_name(style) pygout_style = create_style_from_pygments(style) # Check that all token styles are the same - at this point they haven't # been via TokenStyleEditor. compare_style_lists(style, pygments_style.list_styles(), pygout_style.list_styles()) new_pygout_style = create_style(None, pygout_style.pygout_styles) # Check that a style that's gone via the TokenStyleEditor conversion # still is the same style. compare_style_lists(style, pygout_style.list_styles(), new_pygout_style.list_styles())