write output in files

This commit is contained in:
2020-07-19 15:04:29 +03:00
parent 1c410da387
commit 79f1fd9eed
4 changed files with 13 additions and 17 deletions

View File

@@ -50,7 +50,10 @@ def render_template(name, template):
'fixed_row': 3,
'columns': [c for c in generate_columns()]
}
print(template.render(vals))
filename = os.path.join(os.path.dirname(os.path.dirname(__file__)),'output')
filename = os.path.join(filename, f'{name}.txt')
with open(filename, 'w', encoding='utf8', newline='') as f:
f.write(template.render(vals))
def init_templates():
@@ -67,7 +70,6 @@ def init_templates():
def main():
templates = init_templates()
for template in templates.items():
print(template[0], template[1])
render_template(template[0], template[1])

View File

@@ -1,6 +1,4 @@
{% extends 'base.jinja2' %}
{% block conditions %}
{% for column in columns %}
IF(AND({{column}}{{row_num}}={{column}}${{fixed_row}};{{column}}${{fixed_row}}="Ч");1;0);
{% endfor %}
{% extends 'base.jinja2' %}{% block conditions %}
{% for column in columns %}IF(AND({{column}}{{row_num}}={{column}}${{fixed_row}};{{column}}${{fixed_row}}="Ч");1;0);
{% endfor %}
{% endblock %}

View File

@@ -1,6 +1,4 @@
{% extends 'base.jinja2' %}
{% block conditions %}
{% for column in columns %}
IF({{column}}{{row_num}}={{column}}${{fixed_row}};1;0);
{% endfor %}
{% extends 'base.jinja2' %}{% block conditions %}
{% for column in columns %}IF({{column}}{{row_num}}={{column}}${{fixed_row}};1;0);
{% endfor %}
{% endblock %}

View File

@@ -1,6 +1,4 @@
{% extends 'base.jinja2' %}
{% block conditions %}
{% for column in columns %}
IF(AND({{column}}{{row_num}}={{column}}${{fixed_row}};{{column}}${{fixed_row}}="К");1;0);
{% endfor %}
{% extends 'base.jinja2' %}{% block conditions %}
{% for column in columns %}IF(AND({{column}}{{row_num}}={{column}}${{fixed_row}};{{column}}${{fixed_row}}="К");1;0);
{% endfor %}
{% endblock %}