3 �ga; � @ sn d dl Z d dlmZmZ ddlmZ ddlmZ ddlm Z e j d�Zdd � ZG d d� d�Z G dd � d �ZdS )� N)�Optional�List� )�ConverterPlugin)�plugin_manager)�Environmentz ^[^/]+/[^/]+$c C s | ot j| �S )N)�MIME_RE�match)�mime� r � /usr/lib/python3.6/processing.py� is_valid_mime s r c @ s$ e Zd Zeeee d�dd��ZdS )� Conversion)r �returnc C s0 t | �r,x"tj� D ]}|j| �r|| �S qW d S )N)r r Zget_convertersZsupports)r Zconverter_classr r r � get_converter s zConversion.get_converterN)�__name__� __module__�__qualname__�staticmethod�strr r r r r r r r s r c @ sJ e Zd ZdZe� fee d�dd�Zeed�dd�Zeeed�d d �Z dS )� Formattingz4A delegate class that invokes the actual processors.)�groupsc K sV t j� }g | _xB|D ]:}x4|| D ](}|f d|i|��}|jr"| jj|� q"W qW dS )z� :param groups: names of processor groups to be applied :param env: Environment :param kwargs: additional keyword arguments for processors �envN)r Zget_formatters_grouped�enabled_pluginsZenabled�append)�selfr r �kwargsZavailable_plugins�group�cls�pr r r �__init__ s zFormatting.__init__)�headersr c C s x| j D ]}|j|�}qW |S )N)r �format_headers)r r! r r r r r"