#!/usr/bin/env python3
#
# Format a spec
#

import pscheduler

from validate import spec_is_valid
from validate import MAX_SCHEMA

TEMPLATE='''
{% if _mime_type == 'text/plain' %}
Host ............... {{ unspec(host) }}
Host Node .......... {{ unspec(hostnode) }}
Duration ........... {{ unspec(duration) }}
Starting Comment ... {{ unspec(startingcomment) }}
Parting Comment .... {{ unspec(partingcomment) }}

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

<table>
<tr><td>Host</td><td>{{ unspec(host) }}</td></tr>
<tr><td>Host Node</td><td>{{ unspec(hostnode) }}</td></tr>
<tr><td>Duration</td><td>{{ unspec(duration) }}</td></tr>
<tr><td>Starting Comment</td><td>{{ unspec(startingcomment) }}</td></tr>
<tr><td>Parting Comment</td><td>{{ unspec(partingcomment) }}</td></tr>
</table>

{% else %}

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

{% endif %}
'''

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