o
    N=&b                     @   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.
ZreStructuredText    )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.
    readerZreadersc                 C   s   t | tjtjtjg S N)r   get_transformsr   ZDecorationsZExposeInternalsZStripCommentsself r   =usr/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   Zget_parser_classr   )r   r   Z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   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   )Zreader_namenamemoduleerrr   r   r   get_reader_classf   s   r(   N)r   Z__docformat__	importlibr   docutilsr   r   r   Zdocutils.transformsr   r   r    r"   r(   r   r   r   r   <module>   s   C