Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: convert_js.py

Issue 29481653: Issue 5378 - Stop using of jshydra in libadblockplus (Closed) Base URL: https://github.com/adblockplus/libadblockplus.git
Patch Set: Created July 6, 2017, 1:32 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | lib/compat.js » ('j') | lib/compat.js » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: convert_js.py
diff --git a/convert_js.py b/convert_js.py
index b784a86c171ca3bfef327b974a90d1dcf6fc1847..dc6dc7a7dc7b6276c23c2ec8d21e7e06ee45099d 100755
--- a/convert_js.py
+++ b/convert_js.py
@@ -1,6 +1,7 @@
#!/usr/bin/env python
# coding: utf-8
+import io
import sys
import os
import codecs
@@ -9,10 +10,11 @@ import json
import argparse
import xml.dom.minidom as minidom
-baseDir = os.path.abspath(os.path.dirname(__file__))
-sys.path.append(os.path.join(baseDir, 'adblockpluscore', 'buildtools', 'jshydra'))
-from abp_rewrite import doRewrite
-
+jsTemplate = """require.scopes["%s"] = (function() {
+ let exports = {};
+%s
+ return exports;
+})();"""
class CStringArray:
def __init__(self):
@@ -61,9 +63,11 @@ def convertXMLFile(array, file):
def convertJsFile(array, file):
- converted = doRewrite([os.path.abspath(file)], ['module=true', 'source_repo=https://hg.adblockplus.org/adblockpluscore/'])
- array.add(os.path.basename(file))
- array.add(converted)
+ with io.open(file, encoding="utf-8") as jsFile:
+ jsFileContent = jsFile.read()
+ referenceFileName = os.path.basename(file)
+ array.add(referenceFileName)
+ array.add(jsTemplate % (re.sub("\\.jsm?$", "", referenceFileName), jsFileContent))
def convert(verbatimBefore, convertFiles, verbatimAfter, outFile):
« no previous file with comments | « no previous file | lib/compat.js » ('j') | lib/compat.js » ('J')

Powered by Google App Engine
This is Rietveld