o ?]h@sPdZdZddlmZmZmZGdddeZGdddeZGdd d eZ d S) a This package contains modules for standard tree transforms available to Docutils components. Tree transforms serve a variety of purposes: - To tie up certain syntax-specific "loose ends" that remain after the initial parsing of the input plaintext. These transforms are used to supplement a limited syntax. - To automate the internal linking of the document tree (hyperlink references, footnote references, etc.). - To extract useful information from the document tree. These transforms may be used to construct (for example) indexes and tables of contents. Each transform is an optional step that a Docutils component may choose to perform on the parsed document. reStructuredText) languagesApplicationError TransformSpecc@s eZdZdS)TransformErrorN)__name__ __module__ __qualname__r r >/usr/lib/python3/dist-packages/docutils/transforms/__init__.pyrs rc@s(eZdZdZdZ dddZddZdS) Transformz; Docutils transform component abstract base class. NcCs(||_ ||_ t|jj|j|_dS)zA Initial setup for in-place document transforms. N)document startnoder get_languagesettings language_codereporterlanguage)selfr rr r r __init__*s zTransform.__init__cKstd)z5Override to apply the transform to the document tree.z"subclass must override this method)NotImplementedError)rkwargsr r r apply;szTransform.applyN)rrr __doc__default_priorityrrr r r r r !s   r c@sLeZdZdZddZdddZddZdd d Zd d Zd dZ ddZ dS) Transformerz Stores transforms (`Transform` classes) and applies them to document trees. Also keeps track of components by component type name. cCs:g|_ g|_ ||_ g|_ d|_ i|_ d|_dS)Nr) transformsunknown_reference_resolversr appliedsorted componentsserialno)rr r r r rGszTransformer.__init__NcKs6|dur|j}||}|j||d|fd|_dS)a+ Store a single transform. Use `priority` to override the default. `kwargs` is a dictionary whose contents are passed as keyword arguments to the `apply` method of the transform. This can be used to pass application-specific data to the transform instance. Nr)rget_priority_stringrappendr )rtransform_classpriorityrpriority_stringr r r add_transformas   zTransformer.add_transformcCs4|D]}||j}|j||difqd|_dS)z3Store multiple transforms, with default priorities.Nr)r#rrr$r )rtransform_listr%r'r r r add_transformsos  zTransformer.add_transformscCs<|j}|dur |j}||}|j|||ifd|_dS)z4Store a transform with an associated `pending` node.Nr) transformrr#rr$r )rpendingr&r%r'r r r add_pendingxs   zTransformer.add_pendingcCs|jd7_d||jfS)z Return a string, `priority` combined with `self.serialno`. This ensures FIFO order on transforms with identical priority. z %03d-%03d)r")rr&r r r r#szTransformer.get_priority_stringcCsz|D]}|dur q||||j|j<qd|_g}|D]}||jqtdd|D}|jdd|DdS)z Store each component's default transforms, with default priorities. Also, store components by type name in a mapping for later lookup. Nrcss|]}|j|fVqdSr)r&.0fr r r sz7Transformer.populate_from_components..css|]}|dVqdS)r.Nr r/r r r r2s)r*get_transformsr!component_typer extendr)rr! componentridecorated_listr r r populate_from_componentssz$Transformer.populate_from_componentscCs|jj|jj|jrC|js|j|jd|_|j\}}}}||j|d}|j di||j ||||f|js dSdS)z6Apply all of the stored transforms, in priority order.r.)rNr ) r rattach_observernote_transform_messagerr sortreversepoprrr$)rr&r%r,rr+r r r apply_transformss  zTransformer.apply_transformsr) rrr rrr(r*r-r#r9r?r r r r r@s    rN) r __docformat__docutilsrrrrobjectr rr r r r s