#!/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) }}
Nameserver ... {{ unspec(nameserver) }}
Record ....... {{ unspec(record) }}
Query ........ {{ unspec(query) }}
Timeout ...... {{ unspec(timeout) }}

{% 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>Nameserver</td><td>{{ unspec(nameserver) }}</td></tr>
<tr><td>Record</td><td>{{ unspec(record) }}</td></tr>
<tr><td>Query</td><td>{{ unspec(query) }}</td></tr>
<tr><td>Timeout</td><td>{{ unspec(timeout) }}</td></tr>
</table>

{% else %}

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

{% endif %}
'''

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