Commit a6378abe authored by Yusei Tahara's avatar Yusei Tahara

Local variable `template` is used for different things, it is bad. Use...

Local variable `template` is used for different things, it is bad. Use different variable name for different thing.
parent 9db182e8
...@@ -217,23 +217,23 @@ class Recipe(object): ...@@ -217,23 +217,23 @@ class Recipe(object):
compiled_source = env.compile(source, filename=template) compiled_source = env.compile(source, filename=template)
else: else:
try: try:
compiled_source = compiled_source_cache[self.template] compiled_source = compiled_source_cache[template]
except KeyError: except KeyError:
template = zc.buildout.download.Download( download_path = zc.buildout.download.Download(
self.buildout['buildout'], self.buildout['buildout'],
hash_name=True, hash_name=True,
)( )(
template, template,
md5sum=self.md5sum, md5sum=self.md5sum,
)[0] )[0]
with open(template, 'rb') as f: with open(download_path, 'rb') as f:
source = f.read().decode(self.encoding) source = f.read().decode(self.encoding)
compiled_source_cache[self.template] = compiled_source = env.compile(source, filename=template) compiled_source_cache[template] = compiled_source = env.compile(source, filename=download_path)
template = env.template_class.from_code(env, template_object = env.template_class.from_code(env,
compiled_source, compiled_source,
env.make_globals(None), None) env.make_globals(None), None)
rendered = template.render(**self.context).encode(self.encoding) rendered = template_object.render(**self.context).encode(self.encoding)
mode = self.mode mode = self.mode
mask = (0o777 if rendered.startswith(b'#!') else 0o666 mask = (0o777 if rendered.startswith(b'#!') else 0o666
) if mode is None else 0 ) if mode is None else 0
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment