o
    Ni                     @   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.
    readerreadersc                    s   t   tjtjtjg S N)superget_transformsr   DecorationsExposeInternalsStripCommentsself	__class__ M/home/ubuntu/.local/lib/python3.10/site-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    @   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!   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__component_type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   sx   |   }t||}z
td| }W |jS  ty;   z	t|}W Y |jS  ty: } z
td|  d| d}~ww 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errr   r   r   get_reader_classf   s   r7   N)r*   __docformat__	importlibr   docutilsr   r   r   docutils.transformsr   r   r.   r0   r7   r   r   r   r   <module>   s   C