85 lines
2.2 KiB
Python
85 lines
2.2 KiB
Python
|
#!/usr/bin/env python
|
||
|
|
||
|
"""
|
||
|
Module docstring.
|
||
|
"""
|
||
|
|
||
|
import sys, os, optparse
|
||
|
|
||
|
items = (
|
||
|
"jquery.js",
|
||
|
# "jspolygon.js",
|
||
|
"optimal-select.js",
|
||
|
"hammer.js",
|
||
|
"hammer.propagating.js",
|
||
|
"d3/d3.js",
|
||
|
"d3/d3-selection-multi.js",
|
||
|
"highlight",
|
||
|
"pixi/pixi.js",
|
||
|
"pixi/lib/crn_decomp.js",
|
||
|
"pixi/pixi-compressed-textures.js",
|
||
|
"pixi/pixi-filters.js",
|
||
|
"pixi/pixi-particles.js",
|
||
|
"pixi/pixi-projection.js",
|
||
|
"greensock/src/uncompressed",
|
||
|
"greensock/src/uncompressed/easing",
|
||
|
"greensock/src/uncompressed/plugins",
|
||
|
"greensock/src/uncompressed/utils",
|
||
|
"convertPointFromPageToNode.js"
|
||
|
# "getRelativeURL.js"
|
||
|
)
|
||
|
|
||
|
def process_command_line(argv):
|
||
|
"""
|
||
|
Return a 2-tuple: (settings object, args list).
|
||
|
`argv` is a list of arguments, or `None` for ``sys.argv[1:]``.
|
||
|
"""
|
||
|
if argv is None:
|
||
|
argv = sys.argv[1:]
|
||
|
|
||
|
# initialize the parser object:
|
||
|
parser = optparse.OptionParser(
|
||
|
formatter=optparse.TitledHelpFormatter(width=78),
|
||
|
add_help_option=None)
|
||
|
|
||
|
# define options here:
|
||
|
parser.add_option( # customized description; put --help last
|
||
|
'-h', '--help', action='help',
|
||
|
help='Show this help message and exit.')
|
||
|
|
||
|
settings, args = parser.parse_args(argv)
|
||
|
|
||
|
# check number of arguments, verify values, etc.:
|
||
|
if args:
|
||
|
parser.error('program takes no command-line arguments; '
|
||
|
'"%s" ignored.' % (args,))
|
||
|
|
||
|
# further process settings & args if necessary
|
||
|
|
||
|
return settings, args
|
||
|
|
||
|
def main(argv=None):
|
||
|
settings, args = process_command_line(argv)
|
||
|
run(settings, args)
|
||
|
return 0 # success
|
||
|
|
||
|
def run(settings, args):
|
||
|
with open("all.js", 'w') as outfile:
|
||
|
for item in items:
|
||
|
if item.endswith(".js"):
|
||
|
appendFile(outfile, item)
|
||
|
else:
|
||
|
for filename in os.listdir(item):
|
||
|
if filename.endswith(".js"):
|
||
|
appendFile(outfile, os.path.join(item, filename))
|
||
|
|
||
|
def appendFile(outfile, filename):
|
||
|
with open(filename) as infile:
|
||
|
outfile.write("\n")
|
||
|
outfile.write(infile.read())
|
||
|
print("File appended: " + infile.name)
|
||
|
|
||
|
if __name__ == '__main__':
|
||
|
status = main()
|
||
|
sys.exit(status)
|