提交 5a102611 编写于 作者: A Alexander Alekhin

Merge pull request #19207 from alalek:issue_19198

...@@ -69,11 +69,14 @@ ...@@ -69,11 +69,14 @@
import os, sys, re, json, shutil import os, sys, re, json, shutil
from subprocess import Popen, PIPE, STDOUT from subprocess import Popen, PIPE, STDOUT
PY3 = sys.version_info >= (3, 0)
def make_umd(opencvjs, cvjs): def make_umd(opencvjs, cvjs):
src = open(opencvjs, 'r+b') with open(opencvjs, 'r+b') as src:
dst = open(cvjs, 'w+b')
content = src.read() content = src.read()
dst.seek(0) if PY3: # content is bytes
content = content.decode('utf-8')
with open(cvjs, 'w+b') as dst:
# inspired by https://github.com/umdjs/umd/blob/95563fd6b46f06bda0af143ff67292e7f6ede6b7/templates/returnExportsGlobal.js # inspired by https://github.com/umdjs/umd/blob/95563fd6b46f06bda0af143ff67292e7f6ede6b7/templates/returnExportsGlobal.js
dst.write((""" dst.write(("""
(function (root, factory) { (function (root, factory) {
...@@ -103,7 +106,8 @@ def make_umd(opencvjs, cvjs): ...@@ -103,7 +106,8 @@ def make_umd(opencvjs, cvjs):
Module = {}; Module = {};
return cv(Module); return cv(Module);
})); }));
""" % (content)).lstrip().encode()) """ % (content)).lstrip().encode('utf-8'))
if __name__ == "__main__": if __name__ == "__main__":
if len(sys.argv) > 2: if len(sys.argv) > 2:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册