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

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

import pscheduler

from validate import result_is_valid
from validate import MAX_SCHEMA

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

Duration ... {{ unspec(result.duration) }}

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

<table>
<tr><td>Duration</td><td>{{ unspec(result.duration) }}</td></tr>
</table>

{% else %}

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

{% endif %}
'''

pscheduler.result_format_method(TEMPLATE, max_schema=MAX_SCHEMA, validator=result_is_valid)
