Skip to content

Scrapy, a fast high-level web crawling & scraping framework for Python.

fix string manipulation in render_templatefile()

Νικόλαος-Διγενής Καραγιάννης56b3cf07fff4
diff --git a/scrapy/utils/template.py b/scrapy/utils/template.py
index 1cfcd82ee..90aa8f705 100644
--- a/scrapy/utils/template.py
+++ b/scrapy/utils/template.py
@@ -10,7 +10,8 @@ def render_templatefile(path, **kwargs):
content = string.Template(raw).substitute(**kwargs)
- with open(path.rstrip('.tmpl'), 'wb') as file:
+ render_path = path[:-len('.tmpl')] if path.endswith('.tmpl') else path
+ with open(render_path, 'wb') as file:
file.write(content)
if path.endswith('.tmpl'):
os.remove(path)