def main():
    """
    %prog scriptname.py

    create a minimal boilerplate for a new script
    """
    p = OptionParser(main.__doc__)
    p.add_option("-g", "--graphic", default=False, action="store_true",
            help="Create boilerplate for a graphic script")

    opts, args = p.parse_args()
    if len(args) != 1:
        sys.exit(not p.print_help())

    script, = args
    imports = graphic_imports if opts.graphic else default_imports
    app = graphic_app if opts.graphic else default_app
    template = default_template.format(imports, app)
    write_file(script, template)

    message = "template writes to `{0}`".format(script)
    if opts.graphic:
        message = "graphic " + message
    message = message[0].upper() + message[1:]
    logging.debug(message)
def main ( ) : p = OptionParser ( main . __doc__ ) p . add_option ( "-g" , "--graphic" , default = False , action = "store_true" , help = "Create boilerplate for a graphic script" ) opts , args = p . parse_args ( ) if len ( args ) != 1 : sys . exit ( not p . print_help ( ) ) script , = args imports = graphic_imports if opts . graphic else default_imports app = graphic_app if opts . graphic else default_app template = default_template . format ( imports , app ) write_file ( script , template ) message = "template writes to `{0}`" . format ( script ) if opts . graphic : message = "graphic " + message message = message [ 0 ] . upper ( ) + message [ 1 : ] logging . debug ( message )
%prog scriptname.py

    create a minimal boilerplate for a new script