
    dd                     n    d Z dZddlmZ ddlmZmZmZ ddlm	Z	  G d de      Z
 G d d	e
      Zi Zd
 Zy)z0
This package contains Docutils Reader modules.
reStructuredText    )import_module)utilsparsers	Component)	universalc                   J     e Zd ZdZdZdZ fdZd
dZd Zd Z	d Z
d	 Z xZS )Readera9  
    Abstract base class for docutils Readers.

    Each reader module or package must export a subclass also called 'Reader'.

    The two steps of a Reader's responsibility are to read data from the
    source Input object and parse the data with the Parser object.
    Call `read()` to process a document.
    readerreadersc                     t         |          t        j                  t        j                  t        j
                  gz   S N)superget_transformsr   DecorationsExposeInternalsStripComments)self	__class__s    ;/usr/lib/python3/dist-packages/docutils/readers/__init__.pyr   zReader.get_transforms    s:    w%'9+@+@+4+D+D+4+B+B+D D 	D    c                 \    || _         	 ||r| j                  |       d| _        	 d| _        y)z
        Initialize the Reader instance.

        Several instance attributes are defined with dummy initial values.
        Subclasses may use these attributes as they wish.
        N)parser
set_parsersourceinput)r   r   parser_names      r   __init__zReader.__init__%   s<     	E >kOOK(<
	$r   c                 F    t        j                  |      } |       | _        y)zSet `self.parser` by name.N)r   get_parser_classr   )r   r   parser_classs      r   r   zReader.set_parser;   s    //<"nr   c                     || _         | j                  s|| _        || _        | j                   j                         | _        | j                          | j                  S r   )r   r   settingsreadr   parsedocument)r   r   r   r#   s       r   r$   zReader.read@   sE    {{ DK [[%%'


}}r   c                     | j                         x| _        }| j                  j                  | j                  |       dx|_        |_        y)z(Parse `self.input` into a document tree.N)new_documentr&   r   r%   r   current_sourcecurrent_line)r   r&   s     r   r%   zReader.parseI   s?    #'#4#4#66$**h/:>>("7r   c                 j    t        j                  | j                  j                  | j                        S )z8Create and return a new empty document tree (root node).)r   r(   r   source_pathr#   r   s    r   r(   zReader.new_documentO   s#    !!$++"9"94==IIr   )NN)__name__
__module____qualname____doc__component_typeconfig_sectionr   r   r   r$   r%   r(   __classcell__)r   s   @r   r
   r
      s4     NND
$,%
?Jr   r
   c                       e Zd ZdZd Zy)ReReaderz
    A reader which rereads an existing document tree (e.g. a
    deserializer).

    Often used in conjunction with `writers.UnfilteredWriter`.
    c                 ,    t        j                  |       S r   )r   r   r-   s    r   r   zReReader.get_transforms]   s     ''--r   N)r.   r/   r0   r1   r    r   r   r6   r6   T   s    .r   r6   c                    | 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 Reader class from the `reader_name` module.zdocutils.readers.zReader "z" not found. N)lower_reader_aliasesgetr   ImportErrorr
   )reader_namenamemoduleerrs       r   get_reader_classrB   f   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N)r1   __docformat__	importlibr   docutilsr   r   r   docutils.transformsr   r
   r6   r;   rB   r8   r   r   <module>rG      sF   
 # # . . )@JY @JF.v . r   