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: Check module exists before auto-loading it Created Nov. 30, 2016, 3:24 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 | « dependencies ('k') | releaseAutomation.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: packagerChrome.py
diff --git a/packagerChrome.py b/packagerChrome.py
index b81b665aff62c1fafb1c577632105a8258a3bec9..d679489ee9f3364787db4c7fec7419b8c8d0f9e4 100644
--- a/packagerChrome.py
+++ b/packagerChrome.py
@@ -144,30 +144,44 @@ def createInfoModule(params):
def convertJS(params, files):
- from jshydra.abp_rewrite import rewrite_js
-
output_files = collections.OrderedDict()
- args = collections.defaultdict(list)
+ args = {}
for item in params['metadata'].items('convert_js'):
- filename, arg = re.search(r'^(.*?)(?:\[(.*)\])?$', item[0]).groups()
+ name, value = item
+ filename, arg = re.search(r'^(.*?)(?:\[(.*)\])?$', name).groups()
if arg is None:
- output_files[filename] = (item[1].split(), item.source)
+ output_files[filename] = (value.split(), item.source)
else:
- args[filename].append('{}={}'.format(arg, item[1]))
+ args.setdefault(filename, {})[arg] = value
+
+ template = getTemplate('modules.js.tmpl')
for filename, (input_files, origin) in output_files.iteritems():
if '/' in filename and not files.isIncluded(filename):
continue
+ current_args = args.get(filename, {})
+ current_args['autoload'] = [module for module in
+ current_args.get('autoload', '').split(',')
+ if module != '']
+
base_dir = os.path.dirname(origin)
- jshydra_args = ['--arg', ' '.join(args[filename])]
+ modules = []
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 file:
+ modules.append((module_name, file.read().decode('utf-8')))
files.pop(input_filename, None)
- files[filename] = rewrite_js(jshydra_args)
+ files[filename] = template.render(
+ args=current_args,
+ modules=modules
+ ).encode('utf-8')
def toJson(data):
« no previous file with comments | « dependencies ('k') | releaseAutomation.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld