U
    [Sh                     @   sd   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 deZ
G dd	 d	e
Zi Zd
d ZdS )z0
This package contains Docutils Reader modules.
reStructuredText    )import_module)utilsparsers	Component)	universalc                       sR   e Zd ZdZdZdZ fddZdddZd	d
 Zdd Z	dd Z
dd Z  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.
    readerZreadersc                    s   t   tjtjtjg S N)superget_transformsr   ZDecorationsZExposeInternalsZStripCommentsself	__class__ L/root/rtd-docs/venv/lib/python3.8/site-packages/docutils/readers/__init__.pyr       s    zReader.get_transformsNc                 C   s,   || _ |dk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   Z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   @   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   Zcurrent_sourcecurrent_line)r   r   r   r   r   r   I   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   O   s    zReader.new_document)NN)__name__
__module____qualname____doc__Zcomponent_typeZconfig_sectionr   r   r   r   r   r   __classcell__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&   T   s   r&   c                 C   s   |   }t||}ztd| }W nX tk
r|   zt|}W n6 tk
rv } ztd|  d| W 5 d}~X Y nX Y nX |jS )z6Return the Reader class from the `reader_name` module.zdocutils.readers.zReader "z" not found. N)lower_reader_aliasesgetr   ImportErrorr   )Zreader_namenamemoduleerrr   r   r   get_reader_classf   s    ,r.   N)r$   __docformat__	importlibr   Zdocutilsr   r   r   Zdocutils.transformsr   r   r&   r(   r.   r   r   r   r   <module>   s   C