def main():
    'The entry point for this script.'
    usage = 'usage: %prog [dir] [-b basedir] [-o jsfile]\n        example:\n        %prog\n        %prog assets -o js/jsfy_res.js\n        '
    parser = optparse.OptionParser(usage)
    parser.add_option('-b', '--base', dest='basedir', help='base dir')
    parser.add_option('-o', '--output', dest='outputpath', help='export js file path')
    (options, args) = parser.parse_args()
    if isinstance(options.basedir, str):
        basedir = options.basedir
    else:
        basedir = '.'
    basedir = abspath(basedir)
    if isinstance(options.outputpath, str):
        outputpath = options.outputpath
    else:
        outputpath = './jsfy_res.js'
    fout = open(outputpath, 'w')
    fout.write('// generated with jsfy.py, v0.1 (https://github.com/floatinghotpot/jsfy)\n\n')
    fout.write('var jsfy_res = jsfy_res || {};\n\n')
    if (not basedir.endswith('/')):
        basedir = (basedir + '/')
    for f in args:
        f = abspath(f)
        if isfile(f):
            jsfy_file(f, basedir, fout)
        elif isdir(f):
            jsfy_dir(f, basedir, fout)
    fout.close()
The entry point for this script.
def main():
    
    usage = 'usage: %prog [dir] [-b basedir] [-o jsfile]\n        example:\n        %prog\n        %prog assets -o js/jsfy_res.js\n        '
    parser = optparse.OptionParser(usage)
    parser.add_option('-b', '--base', dest='basedir', help='base dir')
    parser.add_option('-o', '--output', dest='outputpath', help='export js file path')
    (options, args) = parser.parse_args()
    if isinstance(options.basedir, str):
        basedir = options.basedir
    else:
        basedir = '.'
    basedir = abspath(basedir)
    if isinstance(options.outputpath, str):
        outputpath = options.outputpath
    else:
        outputpath = './jsfy_res.js'
    fout = open(outputpath, 'w')
    fout.write('// generated with jsfy.py, v0.1 (https://github.com/floatinghotpot/jsfy)\n\n')
    fout.write('var jsfy_res = jsfy_res || {};\n\n')
    if (not basedir.endswith('/')):
        basedir = (basedir + '/')
    for f in args:
        f = abspath(f)
        if isfile(f):
            jsfy_file(f, basedir, fout)
        elif isdir(f):
            jsfy_dir(f, basedir, fout)
    fout.close()