From 2393374923c1f808c0aff5eca8213f134ad2c649 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Tue, 19 Feb 2019 21:44:26 -0600 Subject: [PATCH] Tweak how 'env' is added to context for mako template upload --- rattail_fabric/core.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/rattail_fabric/core.py b/rattail_fabric/core.py index f409f15..0cf8a9e 100644 --- a/rattail_fabric/core.py +++ b/rattail_fabric/core.py @@ -137,10 +137,14 @@ def upload_mako_template(local_path, remote_path, context={}, encoding='utf_8', """ template = Template(filename=local_path) + # make copy of context; add env to it + context = dict(context) + context['env'] = env + temp_dir = tempfile.mkdtemp(prefix='rattail-fabric.') temp_path = os.path.join(temp_dir, os.path.basename(local_path)) with open(temp_path, 'wb') as f: - text = template.render(env=env, **context) + text = template.render(**context) f.write(text.encode(encoding)) os.chmod(temp_path, os.stat(local_path).st_mode)