z]c@skdZdZddlmZmZmZdefdYZdd dYZdefd YZd S( s 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. treStructuredTexti(t languagestApplicationErrort TransformSpectTransformErrorcBseZRS((t__name__t __module__(((s>/tmp/pip-build-kBFYxq/docutils/docutils/transforms/__init__.pyRst TransformcBs)eZdZdZddZdZRS(s; Docutils transform component abstract base class. cCs4||_||_tj|jj|j|_dS(sA Initial setup for in-place document transforms. N(tdocumentt startnodeRt get_languagetsettingst language_codetreportertlanguage(tselfRR ((s>/tmp/pip-build-kBFYxq/docutils/docutils/transforms/__init__.pyt__init__*s   cKstddS(s5Override to apply the transform to the document tree.s"subclass must override this methodN(tNotImplementedError(Rtkwargs((s>/tmp/pip-build-kBFYxq/docutils/docutils/transforms/__init__.pytapply;sN(RRt__doc__tNonetdefault_priorityRR(((s>/tmp/pip-build-kBFYxq/docutils/docutils/transforms/__init__.pyR!s t TransformercBsSeZdZdZddZdZddZdZdZ dZ RS( s Stores transforms (`Transform` classes) and applies them to document trees. Also keeps track of components by component type name. cCsCg|_g|_||_g|_d|_i|_d|_dS(Ni(t transformstunknown_reference_resolversRtappliedtsortedt componentstserialno(RR((s>/tmp/pip-build-kBFYxq/docutils/docutils/transforms/__init__.pyRGs       cKsP|dkr|j}n|j|}|jj||d|fd|_dS(s+ 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. iN(RRtget_priority_stringRtappendR(Rttransform_classtpriorityRtpriority_string((s>/tmp/pip-build-kBFYxq/docutils/docutils/transforms/__init__.pyt add_transformas    cCsLx<|D]4}|j|j}|jj||difqWd|_dS(s3Store multiple transforms, with default priorities.iN(RRRRRR(Rttransform_listR R"((s>/tmp/pip-build-kBFYxq/docutils/docutils/transforms/__init__.pytadd_transformsos    cCsY|j}|dkr!|j}n|j|}|jj|||ifd|_dS(s4Store a transform with an associated `pending` node.iN(t transformRRRRRR(RtpendingR!R R"((s>/tmp/pip-build-kBFYxq/docutils/docutils/transforms/__init__.pyt add_pendingxs    cCs |jd7_d||jfS(s Return a string, `priority` combined with `self.serialno`. This ensures FIFO order on transforms with identical priority. is %03d-%03d(R(RR!((s>/tmp/pip-build-kBFYxq/docutils/docutils/transforms/__init__.pyRscCsxC|D];}|dkrqn|j|j||j|j/tmp/pip-build-kBFYxq/docutils/docutils/transforms/__init__.pytpopulate_from_componentss    " cCs|jjj|jjx|jr|jsT|jj|jjd|_n|jj\}}}}||jd|}|j ||j j ||||fqWdS(s6Apply all of the stored transforms, in priority order.iR N( RR tattach_observertnote_transform_messageRRR,treversetpopRRR(RR!R R'RR&((s>/tmp/pip-build-kBFYxq/docutils/docutils/transforms/__init__.pytapply_transformss        N( RRRRRR#R%R(RR1R6(((s>/tmp/pip-build-kBFYxq/docutils/docutils/transforms/__init__.pyR@s   N(( Rt __docformat__tdocutilsRRRRRR(((s>/tmp/pip-build-kBFYxq/docutils/docutils/transforms/__init__.pyts