
    ddQ                         d Z dZddlmZ ddlZddlmZmZ ddlmZ  G d de      Z	 G d	 d
e	      Z
i ddddddddddddddddddddddddddddddd d!d"d!d#d$d%Zd& Zy)'z0
This package contains Docutils Writer modules.
reStructuredText    )import_moduleN)	languages	Component)	universalc                   Z     e Zd ZdZdZdZ fdZdZ	 dZ	 dZ		 dZ
	 d Zd Zd Zd	 Z xZS )
Writera  
    Abstract base class for docutils Writers.

    Each writer module or package must export a subclass also called 'Writer'.
    Each writer must support all standard node types listed in
    `docutils.nodes.node_class_names`.

    The `write()` method is the main entry point.
    writerwritersc                     t         |          t        j                  t        j                  t        j
                  gz   S N)superget_transformsr   MessagesFilterMessagesStripClassesAndElements)self	__class__s    ;/usr/lib/python3/dist-packages/docutils/writers/__init__.pyr   zWriter.get_transforms!   s:    w%'9+=+=+4+C+C+4+L+L+N N 	N    Nc                     i | _         y r   )partsr   s    r   __init__zWriter.__init__8   s    
	r   c                     || _         t        j                  |j                  j                  |j
                        | _        || _        | j                          | j                  j                  | j                        S )a/  
        Process a document into its final form.

        Translate `document` (a Docutils document tree) into the Writer's
        native format, and write it out to its `destination` (a
        `docutils.io.Output` subclass object).

        Normally not overridden or extended in subclasses.
        )documentr   get_languagesettingslanguage_codereporterlanguagedestination	translatewriteoutput)r   r   r"   s      r   r$   zWriter.writeA   sd     !!..++ '%%dkk22r   c                     t        d      )a  
        Do final translation of `self.document` into `self.output`.  Called
        from `write`.  Override in subclasses.

        Usually done with a `docutils.nodes.NodeVisitor` subclass, in
        combination with a call to `docutils.nodes.Node.walk()` or
        `docutils.nodes.Node.walkabout()`.  The ``NodeVisitor`` subclass must
        support all standard elements (listed in
        `docutils.nodes.node_class_names`) and possibly non-standard elements
        used by the current Reader as well.
        z"subclass must override this method)NotImplementedErrorr   s    r   r#   zWriter.translateS   s     ""FGGr   c                 $   | j                   | j                  d<   | j                  j                  j                  | j                  d<   | j                  j                  j
                  | j                  d<   t        j                  | j                  d<   y)zAssemble the `self.parts` dictionary.  Extend in subclasses.

        See <https://docutils.sourceforge.io/docs/api/publisher.html>.
        wholeencodingerrorsversionN)r%   r   r   r   output_encodingoutput_encoding_error_handlerdocutils__version__r   s    r   assemble_partszWriter.assemble_partsa   si    
 #kk

7!%!7!7!G!G

:MM""@@ 	

8 ( 4 4

9r   )__name__
__module____qualname____doc__component_typeconfig_sectionr   r   r%   r!   r"   r   r$   r#   r1   __classcell__)r   s   @r   r	   r	      sW     NNN
 HEF
 H=K
3$H	5r   r	   c                       e Zd ZdZd Zy)UnfilteredWriterz
    A writer that passes the document tree on unchanged (e.g. a
    serializer.)

    Documents written by UnfilteredWriters are typically reused at a
    later date using a subclass of `readers.ReReader`.
    c                 ,    t        j                  |       S r   )r   r   r   s    r   r   zUnfilteredWriter.get_transformsw   s     ''--r   N)r2   r3   r4   r5   r    r   r   r:   r:   m   s    .r   r:   html	html4css1html4xhtml10html5html5_polyglotxhtmls5s5_htmllatexlatex2exelatexxetexluatexlualatexodfodf_odtodtooffice
openofficelibreofficepprint	pseudoxmlpformatrlpdfdocutils_xml)pdfxmlc                    | j                         }t        j                  ||      }	 t        d|z         }|j
                  S # t        $ r= 	 t        |      }n"# t        $ r}t	        d|  d|       d}~ww xY wY |j
                  S w xY w)z6Return the Writer class from the `writer_name` module.zdocutils.writers.zWriter "z" not found. N)lower_writer_aliasesgetr   ImportErrorr	   )writer_namenamemoduleerrs       r   get_writer_classrb      s    DtT*DJ2478 ==  J	J"4(F 	J]3%HII	J  ==Js5   A 	BAB	A7!A22A77BB)r5   __docformat__	importlibr   r/   r   r   docutils.transformsr   r	   r:   r[   rb   r<   r   r   <module>rf      s  
 # #  ) )X5Y X5v.v ."k{  	
  I y   ' Y Y  I Y  !" #$ ',r   