U n^ @s`dZdZddlZddlmZmZmZddlmZGdddeZ Gdd d e Z iZ d d Z dS) z0 This package contains Docutils Reader modules. ZreStructuredTextN)utilsparsers Component) universalc@sJeZdZdZdZdZddZdddZd d Zd d Z d dZ ddZ dS)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. readerZreaderscCst|tjtjtjgSN)rget_transformsrZ DecorationsZExposeInternalsZ StripCommentsselfr s/private/var/folders/sd/whlwsn6x1_qgglc0mjv25_695qk2gl/T/pip-install-4zq3fp6i/docutils/docutils/readers/__init__.pyr s zReader.get_transformsNcCs,||_|dkr|r||d|_d|_dS)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_parsersourceinput)r r parser_namer r r __init__&s   zReader.__init__cCst|}||_dS)zSet `self.parser` by name.N)rZget_parser_classr)r rZ parser_classr r r r<s zReader.set_parsercCs2||_|js||_||_|j|_||jSr)rrsettingsreadrparsedocument)r rrrr r r rAs z Reader.readcCs.||_}|j|j|d|_|_dS)z(Parse `self.input` into a document tree.N) new_documentrrrrZcurrent_source current_liner rr r r rJsz Reader.parsecCst|jj|j}|S)z8Create and return a new empty document tree (root node).)rrr source_pathrrr r r rPszReader.new_document)NN) __name__ __module__ __qualname____doc__Zcomponent_typeZconfig_sectionr rrrrrr r r r rs   rc@seZdZdZddZdS)ReReaderz A reader which rereads an existing document tree (e.g. a deserializer). Often used in conjunction with `writers.UnfilteredWriter`. cCs t|Sr)rr r r r r r _szReReader.get_transformsN)rrrrr r r r r r Vsr c Cs`|}|tkrt|}zt|ttdd}Wn(tk rXt|ttdd}YnX|jS)z6Return the Reader class from the `reader_name` module.)levelr)lower_reader_aliases __import__globalslocals ImportErrorr)Z reader_namemoduler r r get_reader_classgsr*) rZ __docformat__sysZdocutilsrrrZdocutils.transformsrrr r$r*r r r r s E