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

Unified Diff: packagerChrome.py

Issue 29363565: Issue 4552 - Drop jshydra dependency (buildtools) (Closed)
Patch Set: Created Nov. 18, 2016, 5:20 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
Index: packagerChrome.py
diff --git a/packagerChrome.py b/packagerChrome.py
index b81b665aff62c1fafb1c577632105a8258a3bec9..22bcac5a6a0e6adf4c7948fe73a3ff192ab09c5f 100644
--- a/packagerChrome.py
+++ b/packagerChrome.py
@@ -144,30 +144,40 @@ def createInfoModule(params):
def convertJS(params, files):
- from jshydra.abp_rewrite import rewrite_js
-
output_files = collections.OrderedDict()
- args = collections.defaultdict(list)
+ args = collections.defaultdict(dict)
for item in params['metadata'].items('convert_js'):
Wladimir Palant 2016/11/30 14:54:44 Nit: `for name, value in ...`? This should make th
kzar 2016/11/30 15:26:17 Well we need item still for `item.source`. How abo
filename, arg = re.search(r'^(.*?)(?:\[(.*)\])?$', item[0]).groups()
if arg is None:
output_files[filename] = (item[1].split(), item.source)
else:
- args[filename].append('{}={}'.format(arg, item[1]))
+ args[filename][arg] = item[1]
Wladimir Palant 2016/11/30 11:39:32 Nit: Frankly, I'd prefer `args.setdefault(filename
kzar 2016/11/30 14:29:44 Done.
+
+ template = getTemplate('modules.js.tmpl', autoEscape=True)
Wladimir Palant 2016/11/30 11:39:32 Please remove autoEscape=True, this isn't an HTML
kzar 2016/11/30 14:29:44 Done.
for filename, (input_files, origin) in output_files.iteritems():
if '/' in filename and not files.isIncluded(filename):
continue
+ args["filename"]["autoload"] = set(args.get("autoload", "").split(","))
Wladimir Palant 2016/11/30 11:39:32 This line has three bugs, I assume that it hasn't
kzar 2016/11/30 14:29:44 Ouch, done.
+
base_dir = os.path.dirname(origin)
- jshydra_args = ['--arg', ' '.join(args[filename])]
+ modules = []
kzar 2016/11/18 17:25:48 List of tuples instead of a dict since the module
for input_filename in input_files:
- jshydra_args.append(os.path.join(base_dir, input_filename))
+ module_name = os.path.splitext(os.path.basename(input_filename))[0]
+ prefix = os.path.basename(os.path.dirname(input_filename))
+ if prefix != "lib":
+ module_name = "{}_{}".format(prefix, module_name)
+ with open(os.path.join(base_dir, input_filename), 'r') as f:
Wladimir Palant 2016/11/30 11:39:32 Nit: file rather than f?
kzar 2016/11/30 14:29:44 Done.
+ modules.append((module_name, f.read().decode('utf-8')))
files.pop(input_filename, None)
- files[filename] = rewrite_js(jshydra_args)
+ files[filename] = template.render(
+ args=args[filename],
+ modules=modules
+ ).encode('utf-8')
def toJson(data):
« no previous file with comments | « dependencies ('k') | templates/modules.js.tmpl » ('j') | templates/modules.js.tmpl » ('J')

Powered by Google App Engine
This is Rietveld