本文整理汇总了Python中mergejs.run函数的典型用法代码示例。如果您正苦于以下问题:Python run函数的具体用法?Python run怎么用?Python run使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了run函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
def main():
web_dev_dir = "../web_dev"
web_dir = "../web"
web_temp_dir = "../web.tmp"
proSoar_merge = "merge_proSoar.conf"
proSoar_javascript = "proSoar.js"
mooTools_merge = "merge_mooTools.conf"
mooTools_javascript = "mooTools.js"
OpenLayers_merge = "merge_OpenLayers.conf"
OpenLayers_javascript = "OpenLayers.js"
print "Depolying proSoar from " + web_dev_dir + " to " + web_dir
if os.path.exists(web_temp_dir):
shutil.rmtree(web_temp_dir)
os.mkdir(web_temp_dir)
os.mkdir(os.path.join(web_temp_dir, 'LC_MESSAGES'))
os.mkdir(os.path.join(web_temp_dir, 'js'))
os.mkdir(os.path.join(web_temp_dir, 'js', 'OpenLayers'))
os.mkdir(os.path.join(web_temp_dir, 'js', 'MooTools'))
# merge proSoar javascript files
print "Merging proSoar javascript files"
try:
proSoar_merged = mergejs.run(os.path.join(web_dev_dir, 'js'), None, proSoar_merge)
except mergejs.MissingImport, E:
print "\nAbnormal termination."
sys.exit("ERROR: %s" % E)
示例2: minify_from_cfg
def minify_from_cfg(minimize, name, source_dir, cfg_name, out_filename, extra_params=None):
"""
Merge+minify JS files from a JS config file (DRY helper for dojs)
"""
info("Compressing %s" % name)
# Merge + minify
merged = mergejs.run(source_dir, None, cfg_name)
if extra_params:
try:
# Assume closure
minimized = minimize(merged, extra_params=extra_params)
except:
# No, not closure
minimized = minimize(merged)
else:
minimized = minimize(merged)
# Write minified file
with open(out_filename, "w") as outFile:
outFile.write(minimized)
# Replace target file
move_to(out_filename, "%s/S3" % source_dir)
示例3: len
#!/usr/bin/env python
import sys
sys.path.append("tools")
import jsmin, mergejs
sourceDirectory = "../js"
configFilename = "ors.cfg"
outputFilename = "ORS.js"
if len(sys.argv) > 1:
configFilename = sys.argv[1] + ".cfg"
if len(sys.argv) > 2:
outputFilename = sys.argv[2]
print "Merging libraries."
merged = mergejs.run(sourceDirectory, None, configFilename)
print "Adding license file."
merged = file("license.txt").read() + merged
print "Writing to %s." % outputFilename
file(outputFilename, "w").write(merged)
print "Done."
示例4: minimize
if use_compressor == "closure":
if not warnings:
closure.extra_params = "--warning_level QUIET"
minimize = closure.minimize
elif use_compressor == "closure_ws":
minimize = closure_ws.minimize
elif use_compressor == "jsmin":
minimize = jsmin.jsmin
sourceDirectory = ".."
configFilename = "sahana.js.cfg"
outputFilename = "S3.min.js"
# Merge JS files
print "Merging Core libraries."
merged = mergejs.run(sourceDirectory, None, configFilename)
# Compress JS files
print "Compressing - JS"
minimized = minimize(merged)
# Add license
print "Adding license file."
minimized = open("license.txt").read() + minimized
# Print to output files
print "Writing to %s." % outputFilename
open(outputFilename, "w").write(minimized)
# Remove old JS files
print "Deleting %s." % outputFilename
示例5: dojs
def dojs(dogis = False):
""" Minifies the js"""
# Define which files we want to include
# also need to amend sahana.js.cfg
configDictCore = {
"web2py": "..",
"T2": "..",
"S3": ".."
}
configFilename = "sahana.js.cfg"
outputFilename = "S3.min.js"
# Merge JS files
print "Merging Core libraries."
(files, order) = mergejs.getFiles(configDictCore, configFilename)
merged = mergejs.run(files, order)
# Compress JS files
print "Compressing - JS"
minimized = jsmin.jsmin(merged)
# Add license
print "Adding license file."
minimized = file("license.txt").read() + minimized
# Print to output files
print "Writing to %s." % outputFilename
file(outputFilename, "w").write(minimized)
# Remove old JS files
print "Deleting %s." % outputFilename
try:
os.remove("../S3/%s" % outputFilename)
except:
pass
# Move new JS files
print "Moving new JS files"
shutil.move("S3.min.js", "../S3")
if dogis:
# also need to amend sahana.js.gis.cfg
configDictGIS = {
"gis": ".."
}
configDictGeoExt = {
"GeoExt.js": "../gis/GeoExt/lib",
"GeoExt": "../gis/GeoExt/lib",
"ux": "../gis/GeoExt"
}
configDictOpenLayers = {
"OpenLayers.js": "../gis/openlayers/lib",
"OpenLayers": "../gis/openlayers/lib",
"Rico": "../gis/openlayers/lib",
"Gears": "../gis/openlayers/lib"
}
configDictGlobalGIS = {}
configDictGlobalGIS.update(configDictOpenLayers)
configDictGlobalGIS.update(configDictGIS)
configFilenameGIS = "sahana.js.gis.cfg"
configFilenameGeoExt = "geoext.js.gis.cfg"
outputFilenameGIS = "OpenLayers.js"
outputFilenameGeoExt = "GeoExt.js"
# Merge GIS JS Files
print "Merging GIS libraries."
(files, order) = mergejs.getFiles(configDictGlobalGIS, configFilenameGIS)
mergedGIS = mergejs.run(files, order)
print "Merging GeoExt libraries."
(files, order) = mergejs.getFiles(configDictGeoExt, configFilenameGeoExt)
mergedGeoExt = mergejs.run(files, order)
# Compress JS files
print "Compressing - GIS JS"
minimizedGIS = jsmin.jsmin(mergedGIS)
print "Compressing - GeoExt JS"
minimizedGeoExt = jsmin.jsmin(mergedGeoExt)
# Add license
minimizedGIS = file("license.gis.txt").read() + minimizedGIS
# Print to output files
print "Writing to %s." % outputFilenameGIS
file(outputFilenameGIS, "w").write(minimizedGIS)
print "Writing to %s." % outputFilenameGeoExt
file(outputFilenameGeoExt, "w").write(minimizedGeoExt)
# Move new JS files
print "Deleting %s." % outputFilenameGIS
try:
os.remove("../gis/%s" % outputFilenameGIS)
except:
pass
print "Moving new GIS JS files"
#.........这里部分代码省略.........
示例6: file
if keep:
newfiles[f] = files[f]
for o in order:
keep = False
for k in configDictMapFish:
if o.startswith(k):
keep = True
break
if keep:
neworder.append(o)
#
# Merge files
#
print "Merging libraries."
merged = mergejs.run(newfiles, neworder)
#
# Compress files
#
if debug:
minimized = merged
else:
print "Compressing."
minimized = jsmin.jsmin(merged)
#
# Add license
#
print "Adding license file."
minimized = file("license.txt").read() + minimized
示例7: build
def build(config_file = None, output_file = None, options = None):
have_compressor = []
try:
import jsmin
have_compressor.append("jsmin")
except ImportError:
print("No jsmin")
try:
# tools/closure_library_jscompiler.py from:
# http://code.google.com/p/closure-library/source/browse/trunk/closure/bin/build/jscompiler.py
import closure_library_jscompiler as closureCompiler
have_compressor.append("closure")
except Exception as E:
print("No closure (%s)" % E)
try:
import closure_ws
have_compressor.append("closure_ws")
except ImportError:
print("No closure_ws")
try:
import minimize
have_compressor.append("minimize")
except ImportError:
print("No minimize")
use_compressor = None
if options.compressor and options.compressor in have_compressor:
use_compressor = options.compressor
sourceDirectory = "../lib"
configFilename = "full.cfg"
outputFilename = "OpenLayers.js"
if config_file:
configFilename = config_file
extension = configFilename[-4:]
if extension != ".cfg":
configFilename = config_file + ".cfg"
if output_file:
outputFilename = output_file
print("Merging libraries.")
try:
if use_compressor == "closure":
sourceFiles = mergejs.getNames(sourceDirectory, configFilename)
else:
merged = mergejs.run(sourceDirectory, None, configFilename)
except mergejs.MissingImport as E:
print("\nAbnormal termination.")
sys.exit("ERROR: %s" % E)
if options.amdname:
options.amdname = "'" + options.amdname + "',"
else:
options.amdname = ""
if options.amd == 'pre':
print("\nAdding AMD function.")
merged = "define(%sfunction(){%sreturn OpenLayers;});" % (options.amdname, merged)
print("Compressing using %s" % use_compressor)
if use_compressor == "jsmin":
minimized = jsmin.jsmin(merged)
elif use_compressor == "minimize":
minimized = minimize.minimize(merged)
elif use_compressor == "closure_ws":
if len(merged) > 1000000: # The maximum file size for this web service is 1000 KB.
print("\nPre-compressing using jsmin")
merged = jsmin.jsmin(merged)
print("\nIs being compressed using Closure Compiler Service.")
try:
minimized = closure_ws.minimize(merged)
except Exception as E:
print("\nAbnormal termination.")
sys.exit("ERROR: Closure Compilation using Web service failed!\n%s" % E)
if len(minimized) <= 2:
print("\nAbnormal termination due to compilation errors.")
sys.exit("ERROR: Closure Compilation using Web service failed!")
else:
print("Closure Compilation using Web service has completed successfully.")
elif use_compressor == "closure":
jscompilerJar = "../tools/closure-compiler.jar"
if not os.path.isfile(jscompilerJar):
print("\nNo closure-compiler.jar; read README.txt!")
sys.exit("ERROR: Closure Compiler \"%s\" does not exist! Read README.txt" % jscompilerJar)
minimized = closureCompiler.Compile(
jscompilerJar,
sourceFiles, [
"--externs", "closure-compiler/Externs.js",
"--jscomp_warning", "checkVars", # To enable "undefinedVars"
"--jscomp_error", "checkRegExp", # Also necessary to enable "undefinedVars"
"--jscomp_error", "undefinedVars"
]
)
if minimized is None:
print("\nAbnormal termination due to compilation errors.")
sys.exit("ERROR: Closure Compilation failed! See compilation errors.")
#.........这里部分代码省略.........
示例8: minimize
print "No closure_ws"
if use_compressor == "closure":
minimize = closure.minimize
elif use_compressor == "closure_ws":
minimize = closure_ws.minimize
elif use_compressor == "jsmin":
minimize = jsmin.jsmin
sourceDirectory = ".."
configFilename = "sahana.js.cfg"
outputFilename = "S3.min.js"
# Merge JS files
print "Merging Core libraries."
merged = mergejs.run(sourceDirectory, None, configFilename)
# Compress JS files
print "Compressing - JS"
minimized = minimize(merged)
# Add license
print "Adding license file."
minimized = file("license.txt").read() + minimized
# Print to output files
print "Writing to %s." % outputFilename
file(outputFilename, "w").write(minimized)
# Remove old JS files
print "Deleting %s." % outputFilename
示例9: file
# merge proSoar javascript files
print "Merging proSoar javascript files"
try:
proSoar_merged = mergejs.run(os.path.join(web_dev_dir, 'js'), None, proSoar_merge)
except mergejs.MissingImport, E:
print "\nAbnormal termination."
sys.exit("ERROR: %s" % E)
print "Writing merged proSoar javascript to " + os.path.join(web_temp_dir, 'js', proSoar_javascript)
file(os.path.join(web_temp_dir, 'js', proSoar_javascript), 'w').write(minify(proSoar_merged))
# merge mooTools javascript files
print "Merging mooTools javascript files"
try:
mooTools_merged = mergejs.run(os.path.join(web_dev_dir, 'js'), None, mooTools_merge)
except mergejs.MissingImport, E:
print "\nAbnormal termination."
sys.exit("ERROR: %s" % E)
print "Writing merged mooTools javascript to " + os.path.join(web_temp_dir, 'js', mooTools_javascript)
file(os.path.join(web_temp_dir, 'js', mooTools_javascript), 'w').write(minify(mooTools_merged))
# merge OpenLayers javascript files
print "Merging OpenLayers javascript files"
try:
OpenLayers_merged = mergejs.run(os.path.join(web_dev_dir, 'js', 'OpenLayers', 'lib'), None, OpenLayers_merge)
except mergejs.MissingImport, E:
print "\nAbnormal termination."
sys.exit("ERROR: %s" % E)