#!/usr/bin/env python3

#
# Development Order #9:
#
# This will format a test spec into something that is human readable.
#

import pscheduler

from validate import spec_is_valid
from validate import MAX_SCHEMA

TEMPLATE='''
{% if _mime_type == 'text/plain' %}

Host .......... {{ unspec(host) }}
Source ........ {{ unspec(source) }}
Destination ... {{ unspec(dest) }}
Duration ...... {{ unspec(duration) }}
Parallel ...... {{ unspec(parallel) }}
Timeout ....... {{ unspec(timeout) }}
Cleanup ....... {{ unspec(cleanup) }}

{% elif _mime_type == 'text/html' %}

<table>
<tr><td>Host</td><td>{{ unspec(host) }}</td></tr>
<tr><td>Source</td><td>{{ unspec(source) }}</td></tr>
<tr><td>Destination</td><td>{{ unspec(destination) }}</td></tr>
<tr><td>Duration</td><td>{{ unspec(duration) }}</td></tr>
<tr><td>Parallel</td><td>{{ unspec(parallel) }}</td></tr>
<tr><td>Timeout</td><td>{{ unspec(timeout) }}</td></tr>
<tr><td>Cleanup</td><td>{{ unspec(cleanup) }}</td></tr>
</table>

{% else %}

{{ error('Unsupported MIME type "' + _mime_type + '"') }}

{% endif %}
'''

pscheduler.spec_format_method(TEMPLATE, max_schema=MAX_SCHEMA, validator=spec_is_valid)
