{{ var_name }} = {{ composer }}.add_stage("Complex Flat File", {{ stage_name }})
{% for prop, value in properties.items() %}
{{ var_name }}.configuration.{{ prop }} = {{ value }}
{% endfor %}

{% if records -%}
{{ var_name }}.configuration.records = [
    {% for record in records -%}
    complex_flat_file.Record(
        name = {{ record["name"] }},
        columns = [
        {% for column in record["columns"] -%}
            complex_flat_file.Column(
                {% for key, prop in column.items()-%}
                {{ key }} = {{ prop }},
                {%- endfor %}
            ),
        {%- endfor %}
        ]
    ),
    {%- endfor %}
]
{%- endif %}

{% if records_id -%}
{{ var_name }}.configuration.records_id = [
    {% for record_id in records_id -%}
    complex_flat_file.RecordID(
        {% for key, prop in record_id.items()-%}
        {{ key }} = {{ prop }},
        {%- endfor %}
    ),
    {%- endfor %}
]
{%- endif %}

{% if constraints -%}
{{ var_name }}.configuration.constraint = [
    {% for constraint in constraints -%}
    complex_flat_file.Constraint(
        {% for key, prop in constraint.items()-%}
        {{ key }} = {{ prop }},
        {%- endfor %}
    ),
    {%- endfor %}
]
{%- endif %}

{% if output_columns -%}
{{ var_name }}.configuration.output_columns = [
    {% for output_column in output_columns -%}
    complex_flat_file.OutputColumns(
        {% for key, prop in output_column.items()-%}
        {{ key }} = {{ prop }},
        {%- endfor %}
    ),
    {%- endfor %}
]
{%- endif %}
