ó
:ÑpDc           @   s   d  Z  d Z d d l Z d d l Z d d l Z d d l Z d d l m Z m Z d d l m	 Z	 m
 Z
 d d l m Z m Z d e f d     YZ d S(	   s(   
Docutils component-related transforms.
t   reStructuredTexti˙˙˙˙N(   t   nodest   utils(   t   ApplicationErrort	   DataError(   t	   Transformt   TransformErrort   Filterc           B   s   e  Z d  Z d Z d   Z RS(   sA  
    Include or exclude elements which depend on a specific Docutils component.

    For use with `nodes.pending` elements.  A "pending" element's dictionary
    attribute ``details`` must contain the keys "component" and "format".  The
    value of ``details['component']`` must match the type name of the
    component the elements depend on (e.g. "writer").  The value of
    ``details['format']`` is the name of a specific format or context of that
    component (e.g. "html").  If the matching Docutils component supports that
    format or context, the "pending" element is replaced by the contents of
    ``details['nodes']`` (a list of nodes); otherwise, the "pending" element
    is removed.

    For example, the reStructuredText "meta" directive creates a "pending"
    element containing a "meta" element (in ``pending.details['nodes']``).
    Only writers (``pending.details['component'] == 'writer'``) supporting the
    "html" format (``pending.details['format'] == 'html'``) will include the
    "meta" element; it will be deleted from the output of all other writers.
    i  c         C   sp   |  j  } | j d } | j d } |  j j j | } | j |  r\ | j | j d  n | j j |  d  S(   Nt	   componentt   formatR   (	   t	   startnodet   detailst   documentt   transformert
   componentst   supportst   replace_selft   parentt   remove(   t   selft   pendingt   component_typeR	   R   (    (    sB   /usr/lib/python2.7/dist-packages/docutils/transforms/components.pyt   apply,   s    	(   t   __name__t
   __module__t   __doc__t   default_priorityR   (    (    (    sB   /usr/lib/python2.7/dist-packages/docutils/transforms/components.pyR      s   (   R   t   __docformat__t   syst   ost   ret   timet   docutilsR   R   R   R   t   docutils.transformsR   R   R   (    (    (    sB   /usr/lib/python2.7/dist-packages/docutils/transforms/components.pyt   <module>   s   