equal
deleted
inserted
replaced
8 import re |
8 import re |
9 import os |
9 import os |
10 from os.path import join, basename, abspath, split, isfile, isdir |
10 from os.path import join, basename, abspath, split, isfile, isdir |
11 from hashlib import md5 |
11 from hashlib import md5 |
12 from optparse import OptionParser |
12 from optparse import OptionParser |
13 from cStringIO import StringIO |
13 from six.moves import cStringIO |
14 |
14 |
15 from svgui.pyjs import pyjs |
15 from svgui.pyjs import pyjs |
16 |
16 |
17 |
17 |
18 usage = """ |
18 usage = """ |
43 # usually defaults to e.g. /usr/share/pyjamas |
43 # usually defaults to e.g. /usr/share/pyjamas |
44 _data_dir = os.path.join(pyjs.prefix, "share/pyjamas") |
44 _data_dir = os.path.join(pyjs.prefix, "share/pyjamas") |
45 |
45 |
46 |
46 |
47 # .cache.html files produces look like this |
47 # .cache.html files produces look like this |
48 CACHE_HTML_PAT = re.compile('^[a-z]*.[0-9a-f]{32}\.cache\.html$') |
48 CACHE_HTML_PAT = re.compile(r'^[a-z]*.[0-9a-f]{32}\.cache\.html$') |
49 |
49 |
50 # ok these are the three "default" library directories, containing |
50 # ok these are the three "default" library directories, containing |
51 # the builtins (str, List, Dict, ord, round, len, range etc.) |
51 # the builtins (str, List, Dict, ord, round, len, range etc.) |
52 # the main pyjamas libraries (pyjamas.ui, pyjamas.Window etc.) |
52 # the main pyjamas libraries (pyjamas.ui, pyjamas.Window etc.) |
53 # and the contributed addons |
53 # and the contributed addons |
182 return |
182 return |
183 if not os.path.isdir(output): |
183 if not os.path.isdir(output): |
184 try: |
184 try: |
185 print("Creating output directory") |
185 print("Creating output directory") |
186 os.mkdir(output) |
186 os.mkdir(output) |
187 except StandardError as e: |
187 except OSError as e: |
188 print("Exception creating output directory %s: %s" % (output, e), file=sys.stderr) |
188 print("Exception creating output directory %s: %s" % (output, e), file=sys.stderr) |
189 |
189 |
190 # public dir |
190 # public dir |
191 for p in pyjs.path: |
191 for p in pyjs.path: |
192 pub_dir = join(p, 'public') |
192 pub_dir = join(p, 'public') |
252 home_nocache_html_output = open(join(output, app_name + ".nocache.html"), |
252 home_nocache_html_output = open(join(output, app_name + ".nocache.html"), |
253 "w") |
253 "w") |
254 |
254 |
255 # the selector templ is added to the selectScript function |
255 # the selector templ is added to the selectScript function |
256 select_tmpl = """O(["true","%s"],"%s");""" |
256 select_tmpl = """O(["true","%s"],"%s");""" |
257 script_selectors = StringIO() |
257 script_selectors = cStringIO() |
258 |
258 |
259 for platform, file_prefix in app_files: |
259 for platform, file_prefix in app_files: |
260 print(select_tmpl % (platform, file_prefix), file=script_selectors) |
260 print(select_tmpl % (platform, file_prefix), file=script_selectors) |
261 |
261 |
262 print( |
262 print( |
451 overnames = "new pyjslib.Dict({\n\t\t%s\n\t})" % ',\n\t\t'.join(overnames) |
451 overnames = "new pyjslib.Dict({\n\t\t%s\n\t})" % ',\n\t\t'.join(overnames) |
452 |
452 |
453 if dynamic: |
453 if dynamic: |
454 mod_cache_html_output = open(join(output, mod_cache_name), "w") |
454 mod_cache_html_output = open(join(output, mod_cache_name), "w") |
455 else: |
455 else: |
456 mod_cache_html_output = StringIO() |
456 mod_cache_html_output = cStringIO() |
457 |
457 |
458 print(mod_cache_html_template % dict( |
458 print(mod_cache_html_template % dict( |
459 mod_name=mod_name, |
459 mod_name=mod_name, |
460 app_name=app_name, |
460 app_name=app_name, |
461 modnames=modnames, |
461 modnames=modnames, |