#!/usr/bin/env python3
# -*- mode: python -*-

from email import message_from_string
from importlib import import_module
import sys

modules = [
    ('aur'),
    ('hackage'),
    ('pypi'),
    ('zovem'),
    ('overquote')
]
## A bit tricky way to get reformat functions and only them
## from modules names list
## In future, this module list will be configurable.

methods = map(lambda m:
		vars(import_module("mailsanity.{0}".format(m)))['reformat'],
              modules)
stdout = open('/dev/stdout', mode = 'w', encoding = 'utf-8')
stdin = open('/dev/stdin', mode = 'r', encoding = 'utf-8')
message = message_from_string(stdin.read())

for method in methods:
    method(message)

stdout.write(message.as_string())
