Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix layout templating #582

Merged
merged 2 commits into from
May 14, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion linchpin/cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,8 @@ def _execute_action(self, action, targets=(), run_id=None, tx_id=None):
if not pf_data_path:
pf = self.parser.process(pf_w_path, data=self.pf_data)
else:
pf = self.parser.process(pf_w_path, data_w_path=pf_data_path)
pf = self.parser.process(pf_w_path,
data='@{0}'.format(pf_data_path))

if pf:
provision_data = self._build(pf, pf_data=self.pf_data)
Expand Down Expand Up @@ -526,6 +527,7 @@ def _build(self, pf, pf_data=None):
if not isinstance(pf[target]['layout'], dict):
layout_path = self.find_include(pf[target]["layout"],
ftype='layout')

layout_data = self.parser.process(layout_path, data=pf_data)
layout_data = self._make_layout_integers(layout_data)
provision_data[target]['layout'] = layout_data
Expand Down
8 changes: 3 additions & 5 deletions linchpin/utils/dataparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def __init__(self):
self._mapping_tag = yaml.resolver.BaseResolver.DEFAULT_MAPPING_TAG


def process(self, file_w_path, data=None, data_w_path=None):
def process(self, file_w_path, data=None):
""" Processes the PinFile and any data (if a template)
using Jinja2. Returns json of PinFile, topology, layout,
and hooks.
Expand All @@ -48,8 +48,6 @@ def process(self, file_w_path, data=None, data_w_path=None):
A JSON representation of data mapped to a Jinja2 template in
file_w_path

:param data_w_path:
If data is passed as a file, this is used
"""

if not data:
Expand All @@ -58,8 +56,8 @@ def process(self, file_w_path, data=None, data_w_path=None):
with open(file_w_path, 'r') as stream:
file_data = stream.read()

if data_w_path:
with open(data_w_path, 'r') as strm:
if data.startswith('@'):
with open(data[1:], 'r') as strm:
data = strm.read()

try:
Expand Down