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: Addressed feedback, make tox pass Created Nov. 30, 2016, 2:23 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') | releaseAutomation.py » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: packagerChrome.py
diff --git a/packagerChrome.py b/packagerChrome.py
index b81b665aff62c1fafb1c577632105a8258a3bec9..6cdef322e277307352cc3fbc767ef6a1786dc8ce 100644
--- a/packagerChrome.py
+++ b/packagerChrome.py
@@ -144,30 +144,43 @@ 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()
if arg is None:
output_files[filename] = (item[1].split(), item.source)
else:
- args[filename].append('{}={}'.format(arg, item[1]))
+ args.setdefault(filename, {})[arg] = item[1]
+
+ 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') | releaseAutomation.py » ('J')

Powered by Google App Engine
This is Rietveld