From 7262f3c975f96fe1aa3ddbcadb00d532452c5ee3 Mon Sep 17 00:00:00 2001 From: Graham Welch Date: Tue, 22 Dec 2015 14:19:52 -0800 Subject: [PATCH] Fully support imports that are dicts containing 'path' and 'content'. --- expandybird/expansion/expansion.py | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/expandybird/expansion/expansion.py b/expandybird/expansion/expansion.py index 3b5e590a0..447a8a219 100755 --- a/expandybird/expansion/expansion.py +++ b/expandybird/expansion/expansion.py @@ -307,19 +307,10 @@ def ExpandTemplate(resource, imports, env, validate_schema=False): source_file, 'Unable to find source file %s in imports.' % (source_file)) - if isinstance(imports[source_file], dict): - # This code path assumes a different structure for the 'imports' param. - # Map of String (name) to Dict ('path', 'content'). - # - # source_file could be a short version of the template - # (say github short name) - # so we need to potentially map this into the fully resolvable name. - if 'path' in imports[source_file] and imports[source_file]['path']: - path = imports[source_file]['path'] - content = imports[source_file]['content'] - else: - path = source_file - content = imports[source_file] + # source_file could be a short version of the template (say github short name) + # so we need to potentially map this into the fully resolvable name. + if 'path' in imports[source_file] and imports[source_file]['path']: + path = imports[source_file]['path'] resource['imports'] = SimpleImportMap(imports) @@ -341,11 +332,11 @@ def ExpandTemplate(resource, imports, env, validate_schema=False): if path.endswith('jinja') or path.endswith('yaml'): expanded_template = ExpandJinja( - source_file, content, resource, imports) + source_file, imports[source_file]['content'], resource, imports) elif path.endswith('py'): # This is a Python template. expanded_template = ExpandPython( - content, source_file, resource) + imports[source_file]['content'], source_file, resource) else: # The source file is not a jinja file or a python file. # This in fact should never happen due to the IsTemplate check above.