diff --git a/utils/build.py b/utils/build.py
index d8eddc2..9424e85 100644
--- a/utils/build.py
+++ b/utils/build.py
@@ -20,102 +20,102 @@ HTML = [
]
def merge(files):
- buffer = []
- for filename in files:
- with open(os.path.join('..', 'src', filename), 'r') as f:
- buffer.append(f.read())
- return "".join(buffer)
+ buffer = []
+ for filename in files:
+ with open(os.path.join('..', 'src', filename), 'r') as f:
+ buffer.append(f.read())
+ return "".join(buffer)
def read(filename):
- with open(os.path.join('..','src',filename), 'r') as f:
- return f.read()
+ with open(os.path.join('..','src',filename), 'r') as f:
+ return f.read()
def output(text, filename):
- with open(os.path.join('..', 'build', filename), 'w') as f:
- f.write(text)
+ with open(os.path.join('..', 'build', filename), 'w') as f:
+ f.write(text)
def JScompress(text):
- in_tuple = tempfile.mkstemp()
- with os.fdopen(in_tuple[0], 'w') as handle:
- handle.write(text)
- out_tuple = tempfile.mkstemp()
- os.system("java -jar compiler.jar --language_in=ECMASCRIPT5 --js %s --js_output_file %s" % (in_tuple[1], out_tuple[1]))
- with os.fdopen(out_tuple[0], 'r') as handle:
- compressed = handle.read()
- os.unlink(in_tuple[1])
- os.unlink(out_tuple[1])
- return compressed
+ in_tuple = tempfile.mkstemp()
+ with os.fdopen(in_tuple[0], 'w') as handle:
+ handle.write(text)
+ out_tuple = tempfile.mkstemp()
+ os.system("java -jar compiler.jar --language_in=ECMASCRIPT5 --js %s --js_output_file %s" % (in_tuple[1], out_tuple[1]))
+ with os.fdopen(out_tuple[0], 'r') as handle:
+ compressed = handle.read()
+ os.unlink(in_tuple[1])
+ os.unlink(out_tuple[1])
+ return compressed
def cssCompress(text):
- in_tuple = tempfile.mkstemp()
- with os.fdopen(in_tuple[0], 'w') as handle:
- handle.write(text)
- out_tuple = tempfile.mkstemp()
- os.system("java -jar yuicompressor-2.4.7.jar %s --type css -o %s --charset utf-8 -v" % (in_tuple[1], out_tuple[1]))
- with os.fdopen(out_tuple[0], 'r') as handle:
- compressed = handle.read()
- os.unlink(in_tuple[1])
- os.unlink(out_tuple[1])
- return compressed
+ in_tuple = tempfile.mkstemp()
+ with os.fdopen(in_tuple[0], 'w') as handle:
+ handle.write(text)
+ out_tuple = tempfile.mkstemp()
+ os.system("java -jar yuicompressor-2.4.7.jar %s --type css -o %s --charset utf-8 -v" % (in_tuple[1], out_tuple[1]))
+ with os.fdopen(out_tuple[0], 'r') as handle:
+ compressed = handle.read()
+ os.unlink(in_tuple[1])
+ os.unlink(out_tuple[1])
+ return compressed
-def htmlCompress(text):
- in_tuple = tempfile.mkstemp()
- with os.fdopen(in_tuple[0], 'w') as handle:
- handle.write(text)
- out_tuple = tempfile.mkstemp()
- os.system("java -jar htmlcompressor-1.5.3.jar --remove-intertag-spaces --remove-quotes -o %s %s" % (out_tuple[1], in_tuple[1]))
- with os.fdopen(out_tuple[0], 'r') as handle:
- compressed = handle.read()
- os.unlink(in_tuple[1])
- os.unlink(out_tuple[1])
- return compressed
+def htmlCompress(text):
+ in_tuple = tempfile.mkstemp()
+ with os.fdopen(in_tuple[0], 'w') as handle:
+ handle.write(text)
+ out_tuple = tempfile.mkstemp()
+ os.system("java -jar htmlcompressor-1.5.3.jar --remove-intertag-spaces --remove-quotes -o %s %s" % (out_tuple[1], in_tuple[1]))
+ with os.fdopen(out_tuple[0], 'r') as handle:
+ compressed = handle.read()
+ os.unlink(in_tuple[1])
+ os.unlink(out_tuple[1])
+ return compressed
def addHeader(text):
- text = text.replace('','');
- header = '\n\n'
- return header + text
+ text = text.replace('','');
+ header = '\n\n'
+ return header + text
def build(files, css, html, filename):
- folder = ''
- os.makedirs('../build', exist_ok=True)
-
- cssfilename = filename + '.css'
- htmlfilename = filename + '.htm'
- filename = filename + '.js'
-
- print('=' * 40)
- print('Compiling', filename)
- print('=' * 40)
-
- js = merge(files)
- js = JScompress(js)
-
- print('=' * 40)
- print('Compiling', cssfilename)
- print('=' * 40)
-
- css = merge(css)
- css = css.replace("'img/grab.svg'","'data:image/svg+xml," + urllib.parse.quote(read('css/img/grab.svg'),'') + "'")
- css = css.replace("'img/grabbing.svg'","'data:image/svg+xml," + urllib.parse.quote(read('css/img/grabbing.svg'),'') + "'")
- css = cssCompress(css)
- css = css.replace("'img/sprites.svg'","'data:image/svg+xml," + urllib.parse.quote(read('css/img/sprites.svg'),'') + "'")
-
- print('=' * 40)
- print('Compiling', htmlfilename)
- print('=' * 40)
-
- html = merge(html)
- html = html.replace('','')
- html = html.replace('','')
- html = html.replace('','')
- html = html.replace('','')
- html = html.replace('"_blank">Pannellum','"_blank">Pannellum ' + read('../VERSION') + '')
- html = htmlCompress(html)
-
- output(addHeader(html), folder + htmlfilename)
+ folder = ''
+ os.makedirs('../build', exist_ok=True)
+
+ cssfilename = filename + '.css'
+ htmlfilename = filename + '.htm'
+ filename = filename + '.js'
+
+ print('=' * 40)
+ print('Compiling', filename)
+ print('=' * 40)
+
+ js = merge(files)
+ js = JScompress(js)
+
+ print('=' * 40)
+ print('Compiling', cssfilename)
+ print('=' * 40)
+
+ css = merge(css)
+ css = css.replace("'img/grab.svg'","'data:image/svg+xml," + urllib.parse.quote(read('css/img/grab.svg'),'') + "'")
+ css = css.replace("'img/grabbing.svg'","'data:image/svg+xml," + urllib.parse.quote(read('css/img/grabbing.svg'),'') + "'")
+ css = cssCompress(css)
+ css = css.replace("'img/sprites.svg'","'data:image/svg+xml," + urllib.parse.quote(read('css/img/sprites.svg'),'') + "'")
+
+ print('=' * 40)
+ print('Compiling', htmlfilename)
+ print('=' * 40)
+
+ html = merge(html)
+ html = html.replace('','')
+ html = html.replace('','')
+ html = html.replace('','')
+ html = html.replace('','')
+ html = html.replace('"_blank">Pannellum','"_blank">Pannellum ' + read('../VERSION') + '')
+ html = htmlCompress(html)
+
+ output(addHeader(html), folder + htmlfilename)
def main():
- build(JS, CSS, HTML, 'pannellum')
+ build(JS, CSS, HTML, 'pannellum')
if __name__ == "__main__":
- main()
+ main()