o
    gJ^‚  ã                   @   sl   d Z dZddlZddlmZ ddlmZmZmZ ddl	m
Z
 G dd„ deƒZG d	d
„ d
eƒZi Zdd„ ZdS )z0
This package contains Docutils Reader modules.
ÚreStructuredTexté    N)Úimport_module)ÚutilsÚparsersÚ	Component)Ú	universalc                   @   sJ   e Zd ZdZdZdZdd„ Zddd„Zd	d
„ Zdd„ Z	dd„ Z
dd„ Zd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                 C   s   t  | ¡tjtjtjg S ©N)r   Úget_transformsr   ÚDecorationsÚExposeInternalsÚStripComments©Úself© r   ú;/usr/lib/python3/dist-packages/docutils/readers/__init__.pyr   !   s
   ýzReader.get_transformsNc                 C   s0   || _ 	 |du r|r|  |¡ d| _	 d| _dS )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_namer   r   r   Ú__init__'   s   
zReader.__init__c                 C   s   t  |¡}|ƒ | _dS )zSet `self.parser` by name.N)r   Úget_parser_classr   )r   r   Úparser_classr   r   r   r   =   s   
zReader.set_parserc                 C   s2   || _ | js	|| _|| _| j  ¡ | _|  ¡  | jS r   )r   r   ÚsettingsÚreadr   ÚparseÚdocument)r   r   r   r   r   r   r   r   B   s   zReader.readc                 C   s.   |   ¡  | _}| j | j|¡ d |_|_dS )z(Parse `self.input` into a document tree.N)Únew_documentr   r   r   r   Úcurrent_sourceÚcurrent_line©r   r   r   r   r   r   K   s   zReader.parsec                 C   s   t  | jj| j¡}|S )z8Create and return a new empty document tree (root node).)r   r    r   Úsource_pathr   r#   r   r   r   r    Q   s   zReader.new_document)NN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Úcomponent_typeÚconfig_sectionr   r   r   r   r   r    r   r   r   r   r      s    

	r   c                   @   s   e Zd ZdZdd„ ZdS )ÚReReaderz•
    A reader which rereads an existing document tree (e.g. a
    deserializer).

    Often used in conjunction with `writers.UnfilteredWriter`.
    c                 C   s
   t  | ¡S r   )r   r   r   r   r   r   r   `   s   
zReReader.get_transformsN)r%   r&   r'   r(   r   r   r   r   r   r+   W   s    r+   c                 C   sL   |   ¡ } | tv rt|  } z
td|  ƒ}W |jS  ty%   t| ƒ}Y |jS w )z6Return the Reader class from the `reader_name` module.zdocutils.readers.)ÚlowerÚ_reader_aliasesr   ÚImportErrorr   )Úreader_nameÚmoduler   r   r   Úget_reader_classh   s   þ
þr1   )r(   Ú__docformat__ÚsysÚ	importlibr   Údocutilsr   r   r   Údocutils.transformsr   r   r+   r-   r1   r   r   r   r   Ú<module>   s   E