nulls in array data
[dygraphs.git] / plotkit_v091 / scripts / pack.py
CommitLineData
6a1aa64f
DV
1#!/usr/bin/env python
2#
3# custom_rhino.jar from:
4# http://dojotoolkit.org/svn/dojo/buildscripts/lib/custom_rhino.jar
5#
6
7import os
8import re
9import sys
10import shutil
11import subprocess
12mk = file('PlotKit/PlotKit.js').read()
13if len(sys.argv) > 1:
14 outf = sys.stdout
15else:
16 outf = file('PlotKit/PlotKit_Packed.js', 'w')
17VERSION = re.search(
18 r"""(?mxs)PlotKit.PlotKit.VERSION\s*=\s*['"]([^'"]+)""",
19 mk
20).group(1)
21if len(sys.argv) > 1:
22 SUBMODULES = sys.argv[1:]
23else:
24 SUBMODULES = map(str.strip, re.search(
25 r"""(?mxs)PlotKit.PlotKit.SUBMODULES\s*=\s*\[([^\]]+)""",
26 mk
27 ).group(1).replace(' ', '').replace('"', '').split(','))
28
29alltext = '\n'.join(
30 [file('PlotKit/%s.js' % m).read() for m in SUBMODULES])
31
32tf = file('_scratch.js', 'w')
33tf.write(alltext)
34tf.flush()
35
36p = subprocess.Popen(
37 ['java', '-jar', 'scripts/custom_rhino.jar', '-c', tf.name],
38 stdout=subprocess.PIPE,
39)
40print >>outf, """/***
41
42 PlotKit.PlotKit %(VERSION)s : PACKED VERSION
43
44 THIS FILE IS AUTOMATICALLY GENERATED. If creating patches, please
45 diff against the source tree, not this file.
46
47 For more information, <http://www.liquidx.net/plotkit/>.
48
49 Copyright (c) 2006. Alastair Tse.
50
51***/
52""" % locals()
53shutil.copyfileobj(p.stdout, outf)
54outf.write('\n')
55outf.flush()
56outf.close()
57tf.close()
58os.remove(tf.name)