U n‰^ç1ã"@s dZdZddlZddlZddlZddlZddlZddlZGdd„deƒZ ej dkrdGdd„de ƒZ ne Z d d „Z �dFd d „ZGdd„de e ƒZGdd„de ƒZGdd„deƒZGdd„deƒZGdd„dƒZGdd„dƒZGdd„dƒZGdd„dƒZGdd„dƒZGd d!„d!ƒZGd"d#„d#eƒZGd$d%„d%ƒZGd&d'„d'ƒZGd(d)„d)eƒZGd*d+„d+eƒZGd,d-„d-eƒZGd.d/„d/eƒZGd0d1„d1eƒZ Gd2d3„d3ƒZ!Gd4d5„d5ƒZ"Gd6d7„d7eƒZ#Gd8d9„d9eƒZ$Gd:d;„d;ƒZ%Gdd?„d?eeeƒZ'Gd@dA„dAeeeƒZ(GdBdC„dCeeƒZ)GdDdE„dEeeƒZ*GdFdG„dGeeƒZ+GdHdI„dIeeƒZ,GdJdK„dKeeƒZ-GdLdM„dMeeƒZ.GdNdO„dOeeƒZ/GdPdQ„dQeeƒZ0GdRdS„dSeeƒZ1GdTdU„dUeeƒZ2GdVdW„dWeeƒZ3GdXdY„dYeeƒZ4GdZd[„d[eeƒZ5Gd\d]„d]eeƒZ6Gd^d_„d_eeƒZ7Gd`da„daeeƒZ8Gdbdc„dceeƒZ9Gddde„deeeƒZ:Gdfdg„dgeeƒZ;Gdhdi„dieeƒZGdndo„doeeƒZ?Gdpdq„dqeeƒZ@Gdrds„dse!eƒZAGdtdu„dueeƒZBGdvdw„dwe!eƒZCGdxdy„dye!eƒZDGdzd{„d{e!eƒZEGd|d}„d}e!eƒZFGd~d„deeƒZGGd€d�„d�e!eƒZHGd‚dƒ„dƒe!eƒZIGd„d…„d…e!eƒZJGd†d‡„d‡e!eƒZKGdˆd‰„d‰e!eƒZLGdŠd‹„d‹e!eƒZMGdŒd�„d�eeƒZNGdŽd�„d�e!eƒZOGd�d‘„d‘e!eƒZPGd’d“„d“e!eƒZQGd”d•„d•eeƒZRGd–d—„d—eeƒZSGd˜d™„d™eeƒZTGdšd›„d›eeƒZUGdœd�„d�e!eƒZVGdždŸ„dŸeeƒZWGd d¡„d¡e!eƒZXGd¢d£„d£eeƒZYGd¤d¥„d¥eeƒZZGd¦d§„d§eeƒZ[Gd¨d©„d©eeƒZ\Gdªd«„d«eeƒZ]Gd¬d­„d­eeƒZ^Gd®d¯„d¯eeƒZ_Gd°d±„d±eeƒZ`Gd²d³„d³eeƒZaGd´dµ„dµeeƒZbGd¶d·„d·ee eƒZcGd¸d¹„d¹ee eƒZdGdºd»„d»ee e"ee$ƒZeGd¼d½„d½eeee%e$ƒZfGd¾d¿„d¿eeee%e$ƒZgGdÀdÁ„dÁe!eƒZhGdÂdÄdÃeeƒZiGdÄdÅ„dÅe!eƒZjGdÆdÇ„dÇe!eƒZkGdÈdÉ„dÉeeƒZlGdÊdË„dËe!eƒZmGdÌdÍ„dÍe!eƒZnGdÎdÏ„dÏe!eƒZoGdÐdÑ„dÑe!eƒZpGdÒdÓ„dÓe!eƒZqGdÔdÕ„dÕe!eƒZrGdÖdׄd×eeeeƒZsGdØdÙ„dÙee eƒZtGdÚdÛ„dÛee"eeƒZuGdÜdÝ„dÝe"eƒZvGdÞdß„dße"eƒZwGdàdá„dáe"eƒZxGdâdã„dãee"e#eƒZyGdädå„dåe"e#eƒZzGdædç„dçe"e#eƒZ{Gdèdé„dée"eƒZ|Gdêdë„dëe"eƒZ}Gdìdí„díe"eƒZ~Gdîdï„dïe"eƒZGdðdñ„dñe"eƒZ€Gdòdó„dóe"eƒZ�Gdôdõ„dõe"eƒZ‚Gdöd÷„d÷ee"eƒZƒGdødù„dùe"eƒZ„Gdúdû„dûe"eƒZ…Gdüdý„dýe"eƒZ†dþ ‡¡ZˆGdÿ�d„�dƒZ‰G�d�d„�de‰ƒZŠG�d�d„�de‰ƒZ‹�d�d„ZŒ�d�d„Z��d �d „ZŽ�d �d „Z�e�eˆƒG�d �d„�de‹ƒZ�G�d�d„�de‘ƒZ’G�d�d„�de’ƒZ“G�d�d„�de’ƒZ”G�d�d„�de’ƒZ•G�d�d„�de’ƒZ–G�d�d„�de’ƒZ—G�d�d„�de’ƒZ˜�d�d„Z™e š�d¡Z›e š�d ¡Zœ�d!�d"�d#�d$�d%�d&�d'�d'�d(�d"�d)�d*�d%�d+�d,�d&�d&�d-�d.�d/�d.�d%�d+�d&�d0�d(�d1�d.�d2�d0�d3�d4�d-�d5œ!Z��d6�d7�d8�d9�d:�d;œZž�d<�d=„ZŸ�d>�d?„Z �d@�dA„Z¡�dB�dC„Z¢�dD�dE„Z£dS(GaØ Docutils document tree element class library. Classes in CamelCase are abstract base classes or auxiliary classes. The one exception is `Text`, for a text (PCDATA) node; uppercase is used to differentiate from element classes. Classes in lower_case_with_underscores are element classes, matching the XML element generic identifiers in the DTD_. The position of each node (the level at which it can occur) is significant and is represented by abstract base classes (`Root`, `Structural`, `Body`, `Inline`, etc.). Certain transformations will be easier because we can use ``isinstance(node, base_class)`` to determine the position of the node in the hierarchy. .. _DTD: http://docutils.sourceforge.net/docs/ref/docutils.dtd ZreStructuredTextéNc@s¢eZdZdZdZdZdZdZdd„Ze j dkr6dd„Z d$dd „Z d%d d „Z dd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„Zd&d d!„Zd'd"d#„ZdS)(ÚNodez0Abstract base class of nodes in a document tree.NcCsdS)a8 Node instances are always true, even if they're empty. A node is more than a simple container. Its boolean "truth" does not depend on having one or more subnodes in the doctree. Use `len()` to check node length. Use `None` to represent a boolean false value. T©©Úselfrrúh/private/var/folders/sd/whlwsn6x1_qgglc0mjv25_695qk2gl/T/pip-install-4zq3fp6i/docutils/docutils/nodes.pyÚ__bool__4s z Node.__bool__©écCst|ƒ d¡S)NZraw_unicode_escape)ÚstrÚencoderrrrÚ__str__Bsz Node.__str__cCs,|dkrddlmm}| ¡}| |¡S)z6Return a DOM **fragment** representation of this Node.Nr)Úxml.dom.minidomÚdomÚminidomÚDocumentÚ _dom_node©rrÚdomrootrrrÚasdomEsz Node.asdomú rcCst‚dS)zs Return an indented pseudo-XML representation, for test purposes. Override in subclasses. N©ÚNotImplementedError©rÚindentÚlevelrrrÚpformatLsz Node.pformatcCst‚dS)zReturn a copy of self.NrrrrrÚcopyTsz Node.copycCst‚dS)z3Return a deep copy of self (also copying children).NrrrrrÚdeepcopyXsz Node.deepcopycCst‚dS)z,Return a string representation of this Node.NrrrrrÚastext\sz Node.astextcCs@||_|jr<|j|_|jdkr(|jj|_|jdkr<|jj|_dS©N)ÚparentÚdocumentÚsourceÚcurrent_sourceÚlineÚ current_line)rÚchildrrrÚ setup_child`s   zNode.setup_childc CsÀd}|jj d|jj¡zˆz| |¡Wn0ttfk rH|YWStk rZYnX|j }z(|dd…D]}|  |¡rpd}qˆqpWnt k ržYnXWnt k rºd}YnX|S)aé Traverse a tree of `Node` objects, calling the `dispatch_visit()` method of `visitor` when entering each node. (The `walkabout()` method is similar, except it also calls the `dispatch_departure()` method before exiting each node.) This tree traversal supports limited in-place tree modifications. Replacing one node with one or more nodes is OK, as is removing an element. However, if the node removed or replaced occurs after the current node, the old node will still be traversed, and any new nodes will not. Within ``visit`` methods (and ``depart`` methods for `walkabout()`), `TreePruningException` subclasses may be raised (`SkipChildren`, `SkipSiblings`, `SkipNode`, `SkipDeparture`). Parameter `visitor`: A `NodeVisitor` object, containing a ``visit`` implementation for each `Node` subclass encountered. Return true if we should stop the traversal. Fz6docutils.nodes.Node.walk calling dispatch_visit for %sNT) r!ÚreporterÚdebugÚ __class__Ú__name__Údispatch_visitÚ SkipChildrenÚSkipNodeÚ SkipDepartureÚchildrenÚwalkÚ SkipSiblingsÚ StopTraversal)rÚvisitorÚstopr0r&rrrr1is0ÿÿ     z Node.walkcCsúd}d}|jj d|jj¡zˆz| |¡Wn0tk rH|YWStk r^d}YnX|j}z(|dd…D]}|  |¡rtd}qŒqtWnt k r¢YnXWn*t k rºYnt k rÐd}YnX|rö|jj d|jj¡|  |¡|S)a† Perform a tree traversal similarly to `Node.walk()` (which see), except also call the `dispatch_departure()` method before exiting each node. Parameter `visitor`: A `NodeVisitor` object, containing a ``visit`` and ``depart`` implementation for each `Node` subclass encountered. Return true if we should stop the traversal. TFz;docutils.nodes.Node.walkabout calling dispatch_visit for %sNz?docutils.nodes.Node.walkabout calling dispatch_departure for %s)r!r(r)r*r+r,r.r/r0Ú walkaboutr2r-r3Údispatch_departure)rr4Z call_departr5r0r&rrrr6—sD ÿÿ      ÿÿ zNode.walkaboutcCs8g}t||ƒr| |¡|jD]}| | |¡¡q|S)z:Specialized traverse() that only supports instance checks.)Ú isinstanceÚappendr0ÚextendÚ_fast_traverse)rÚclsÚresultr&rrrr;Âs    zNode._fast_traversecCs,g}| |¡|jD]}| | ¡¡q|S)z:Specialized traverse() that doesn't check for a condition.)r9r0r:Ú _all_traverse)rr=r&rrrr>Ës   zNode._all_traverseTFc Cs|rd}|r8|r8|s8|dkr$| ¡St|tƒr8| |¡St|tƒrR|}|fdd„}g}|rt|dksj||ƒrt| |¡|r¦t|jƒr¦|D]}| |jdddd|d�¡q†|s°|�r|} | j �r| j   | ¡} | j | dd…D]} | | jd|dd|d�¡qÚ|�s�qq´| j } q´|S)a Return an iterable containing * self (if include_self is true) * all descendants in tree traversal order (if descend is true) * all siblings (if siblings is true) and their descendants (if also descend is true) * the siblings of the parent (if ascend is true) and their descendants (if also descend is true), and so on If `condition` is not None, the iterable contains only nodes for which ``condition(node)`` is true. If `condition` is a node class ``cls``, it is equivalent to a function consisting of ``return isinstance(node, cls)``. If ascend is true, assume siblings to be true as well. For example, given the following tree:: <--- emphasis.traverse() and <--- strong.traverse() are called. Foo Bar Baz Then list(emphasis.traverse()) equals :: [, , <#text: Foo>, <#text: Bar>] and list(strong.traverse(ascend=True)) equals :: [, <#text: Foo>, <#text: Bar>, , <#text: Baz>] TNcSs t||ƒSr)r8)ÚnodeÚ node_classrrrÚ conditionsz Node.traverse..conditionF)Ú include_selfÚdescendÚsiblingsÚascendrAé) r>r8Útyper;r9Úlenr0r:Útraverser Úindex) rrArBrCrDrEr@Úrr&r?rJZsiblingrrrrIÓsF%       þ    ý z Node.traversecCs:|j|||||d�}z |dWStk r4YdSXdS)zä Return the first node in the iterable returned by traverse(), or None if the iterable is empty. Parameter list is the same as of traverse. Note that include_self defaults to 0, though. )rArBrCrDrErN)rIÚ IndexError)rrArBrCrDrEÚiterablerrrÚ next_nodes þ zNode.next_node)N)rr)NTTFF)NFTFF)r+Ú __module__Ú __qualname__Ú__doc__r r!r"r$rÚsysÚ version_infor rrrrrr'r1r6r;r>rIrNrrrrr$s4    .+ ÿ Kÿrrc@seZdZdZdd„ZdS)Ú reprunicodezU A unicode sub-class that removes the initial u from unicode's repr. cCst |¡dd…S©NrF)r Ú__repr__rrrrrV5szreprunicode.__repr__N)r+rOrPrQrVrrrrrT0srTcCs$tjdkr t|tƒr | dd¡S|S)z4 Failsave conversion of `unicode` to `str`. rÚasciiÚbackslashreplace)rRrSr8r r )ÚsrrrÚ ensure_str;s rZFcCs2|r| dd¡SdD]}d | |¡¡}q|SdS)zw Return a string with nulls removed or restored to backslashes. Backslash-escaped spaces are also removed. úú\)z z r[ÚN)ÚreplaceÚjoinÚsplit)ÚtextZrestore_backslashesZrespect_whitespaceÚseprrrÚunescapeDs  rcc@s’eZdZdZdZdZejdkr*d!dd„Zn d"dd„Zd#d d „Z d$d d„Z dd„Z dd„Z dd„Z dd„Zdd„Zd%dd„Zd&dd„Zd'dd „ZdS)(ÚTextzÐ Instances are terminal nodes (leaves) containing text only; no child nodes or attributes. Initialize by passing a string to the constructor. Access the text itself with the `astext` method. z#textrrNcCst|tƒrtdƒ‚t ||¡S)ú7Prevent the rawsource argument from propagating to str.zexpecting str data, not bytes)r8ÚbytesÚ TypeErrorrTÚ__new__©r<ÚdataÚ rawsourcerrrrh`s z Text.__new__cCs t ||¡S)re)rTrhrirrrrhfsr]cCs ||_dSr©rk)rrjrkrrrÚ__init__jsz Text.__init__écCs6|}t|ƒ|kr$|d|d…d}d|jt|ƒfS)Néú ...z<%s: %r>)rHÚtagnamerT)rÚmaxlenrjrrrÚ shortreprns zText.shortreprcCs |jdd�S)NéD)rr)rsrrrrrVtsz Text.__repr__cCs| t|ƒ¡Sr)ZcreateTextNoder )rrrrrrwszText._dom_nodecCs tt|ƒƒSr)rTrcrrrrrzsz Text.astextcCs|jt|ƒ|jd�S)Nrl)r*rTrkrrrrr†sz Text.copycCs| ¡Sr)rrrrrr‰sz Text.deepcopyrrcs8ˆ|‰‡fdd„| ¡ ¡Dƒ}|s*dSd |¡dS)Ncsg|] }ˆ|‘qSrr©Ú.0r$©rrrÚ Žsz Text.pformat..r]Ú )rÚ splitlinesr_)rrrÚlinesrrwrrŒs z Text.pformatcCs| t ||¡|j¡Sr)r*rTÚrstriprk©rÚcharsrrrr|—sz Text.rstripcCs| t ||¡|j¡Sr)r*rTÚlstriprkr}rrrršsz Text.lstrip)N)N)r])rn)rr)N)N)r+rOrPrQrqr0rRrSrhrmrsrVrrrrrr|rrrrrrdRs        rdc@sBeZdZdZdZdZeeZedZdZdZ d~dd „Z d d „Z d d „Z dd„Z dd„ZejdkrdeZddd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd „Zd!d"„Zd#d$„Zd%d&„Zd'd(„Zd)d*„Zd+d,„Zd-d.„Zd€d/d0„Z d1d2„Z!d3d4„Z"d�d5d6„Z#e!Z$e!Zd‚d7d8„Z%d9d:„Z&d;d<„Z'd=d>„Z(dƒd@dA„Z)dBdC„Z*dDdE„Z+dFdG„Z,dHdI„Z-dJdK„Z.dLdM„Z/d„dOdP„Z0d…dQdR„Z1dSdT„Z2dUdV„Z3dWdX„Z4e4dNdYfdZd[„Z5d†d\d]„Z6d‡d^d_„Z7dˆd`da„Z8d‰dbdc„Z9ddde„Z:dfdg„Z;dhdi„Zdjej=fdmdn„Z?dŠdpdq„Z@drds„ZAdtdu„ZBdvdw„ZCd‹dxdy„ZDeEdzd{„ƒZFeEd|d}„ƒZGdS)ŒÚElementa‰ `Element` is the superclass to all specific elements. Elements contain attributes and child nodes. Elements emulate dictionaries for attributes, indexing by attribute name (a string). To set the attribute 'att' to 'value', do:: element['att'] = 'value' There are two special attributes: 'ids' and 'names'. Both are lists of unique identifiers, and names serve as human interfaces to IDs. Names are case- and whitespace-normalized (see the fully_normalize_name() function), and IDs conform to the regular expression ``[a-z](-?[a-z0-9]+)*`` (see the make_id() function). Elements also emulate lists for child nodes (element nodes and/or text nodes), indexing by integer. To get the first child node, use:: element[0] Elements may be constructed using the ``+=`` operator. To add one new child node to element, do:: element += node This is equivalent to ``element.append(node)``. To add a list of multiple child nodes at once, use the same ``+=`` operator:: element += [node1, node2] This is equivalent to ``element.extend([node1, node2])``. )ÚidsÚclassesÚnamesÚdupnames)Úbackrefs)r"rkNz r]cOs�||_g|_| |¡i|_|jD]}g|j|<q"t| ¡ƒD]8\}}| ¡}||jkrl|dd…|j|<q>||j|<q>|jdkrŒ|j j |_dSr) rkr0r:Ú attributesÚlist_attributesÚlistÚitemsÚlowerrqr*r+)rrkr0r†ÚattÚvaluerrrrmÛs      zElement.__init__cCsl| |j¡}| ¡D]6\}}t|tƒr:d dd„|Dƒ¡}| |d|¡q|jD]}| |  |¡¡qR|S)Nú cSsg|]}td|fƒ‘qS©ú%s©Ú serial_escape©rvÚvrrrrxýsz%Element._dom_node..r�) Ú createElementrqÚattlistr8rˆr_Z setAttributer0Ú appendChildr)rrÚelementÚ attributerŒr&rrrrùs   zElement._dom_nodecCs~d}|jD]0}|| ¡7}t|ƒdkr |dd…d}qú; cSsg|] }t|ƒ‘qSr©rZ©rvÚnrrrrx sz$Element.__repr__..z<%s: %s>)r0rsrHr*r+r_)rrjÚcrrrrVs   ÿzElement.__repr__cCs:|dr,d|jjd dd„|dDƒ¡fSd|jSdS)Nrƒz <%s "%s"...>r›cSsg|] }t|ƒ‘qSrrœr�rrrrxsz%Element.shortrepr..z<%s...>)r*r+r_rqrrrrrss ÿzElement.shortreprcCs:|jr.d| ¡d dd„|jDƒ¡| ¡fS| ¡SdS)Nz%s%s%sr]cSsg|] }t|ƒ‘qSr)r )rvrŸrrrrxsz'Element.__unicode__..)r0Ústarttagr_ÚendtagÚemptytagrrrrÚ __unicode__s þzElement.__unicode__rcCs’|dkr t}|jg}| ¡D]f\}}|dkr<| d|¡qt|tƒr`dd„|Dƒ}d |¡}nt|ƒ}||ƒ}| d||f¡qdd |¡S)Nz %s="True"cSsg|]}td|fƒ‘qSrŽr�r’rrrrx-sz$Element.starttag..r�z%s=%sz<%s>)Úpseudo_quoteattrrqr•r9r8rˆr_r )rÚ quoteattrÚpartsÚnamerŒÚvaluesrrrr #s  zElement.starttagcCs d|jS)Nz)rqrrrrr¡5szElement.endtagcCs$dd |jgdd„| ¡Dƒ¡S)Nz<%s/>r�cSsg|]\}}d||f‘qS)z%s="%s"r)rvržr“rrrrx:sÿz$Element.emptytag..)r_rqr•rrrrr¢8s  ÿÿzElement.emptytagcCs t|jƒSr)rHr0rrrrÚ__len__=szElement.__len__cCst|tƒr||jkS||jkSr)r8r r†r0©rÚkeyrrrÚ __contains__@s  zElement.__contains__cCsbt|tƒr|j|St|tƒr(|j|St|tƒrV|jdksDtdƒ‚|j|j|j …St dƒ‚dS©NrUúcannot handle slice with stridezFelement index must be an integer, a slice, or an attribute name string© r8r r†Úintr0ÚsliceÚstepÚAssertionErrorÚstartr5rgrªrrrÚ __getitem__Gs     zElement.__getitem__cCsŠt|tƒr||jt|ƒ<nlt|tƒr:| |¡||j|<nLt|tƒr~|jdksVtdƒ‚|D]}| |¡qZ||j|j |j …<nt dƒ‚dSr­) r8r r†r°r'r0r±r²r³r´r5rg)rr«Úitemr?rrrÚ __setitem__Ss      zElement.__setitem__cCsbt|tƒr|j|=nJt|tƒr(|j|=n6t|tƒrV|jdksDtdƒ‚|j|j|j …=nt dƒ‚dS)NrUr®zMelement index must be an integer, a simple slice, or an attribute name stringr¯rªrrrÚ __delitem__bs     zElement.__delitem__cCs |j|Sr©r0©rÚotherrrrÚ__add__nszElement.__add__cCs ||jSrr¹rºrrrÚ__radd__qszElement.__radd__cCs,t|tƒr| |¡n|dk r(| |¡|S)z4Append a node or a list of nodes to `self.children`.N)r8rr9r:rºrrrÚ__iadd__ts    zElement.__iadd__cCs|j dd„|jDƒ¡S)NcSsg|] }| ¡‘qSr)r©rvr&rrrrx~sz"Element.astext..)Úchild_text_separatorr_r0rrrrr|sÿzElement.astextcCs2i}t|j ¡ƒD]\}}| |¡r|||<q|Sr)rˆr†r‰Úis_not_default)rZattsr«rŒrrrÚnon_default_attributes€s   zElement.non_default_attributescCst| ¡ ¡ƒ}| ¡|Sr)rˆrÂr‰Úsort)rr•rrrr•‡szElement.attlistcCs|j ||¡Sr)r†Úget©rr«ÚfailobjrrrrÄŒsz Element.getcCs ||jkSr©r†©rÚattrrrrÚhasattr�szElement.hasattrcCs||jkr|j|=dSrrÇrÈrrrÚdelattr’s zElement.delattrcCs|j ||¡Sr)r†Ú setdefaultrÅrrrrÌ–szElement.setdefaultcCsX| dg¡D]}| d¡r |dd…Sq z|j |¡WStk rR|YSXdS)zîReturn node's language tag. Look iteratively in self and parents for a class argument starting with ``language-`` and return the remainder of it (which should be a `BCP49` language tag) or the `fallback`. r‚z language-é N)rÄÚ startswithr Z get_languageÚAttributeError)rÚfallbackr<rrrÚget_language_codežs zElement.get_language_codecCs| |¡|j |¡dSr)r'r0r9©rr¶rrrr9­s zElement.appendcCs|D]}| |¡qdSr©r9)rr¶r?rrrr:±szElement.extendcCs<t|tƒr$| |¡|j ||¡n|dk r8||||…<dSr)r8rr'r0Úinsert)rrJr¶rrrrÔµs   zElement.insertéÿÿÿÿcCs |j |¡Sr)r0Úpop)rÚirrrrÖ¼sz Element.popcCs|j |¡dSr)r0ÚremoverÒrrrrØ¿szElement.removecCs |j |¡Sr)r0rJrÒrrrrJÂsz Element.indexcCs"||gkr||jkrdSdSdS)NrrF©r‡rªrrrrÁÅszElement.is_not_defaultcCs4t|tƒr|j}|jD]}| || |g¡¡qdS)zŒ Update basic attributes ('ids', 'names', 'classes', 'dupnames', but not 'source') from node or dictionary `dict_`. N)r8rr†Úbasic_attributesÚappend_attr_listrÄ)rÚdict_r‹rrrÚupdate_basic_attsËs  zElement.update_basic_attscCs(|D]}|||kr|| |¡qdS)zÜ For each element in values, if it does not exist in self[attr], append it. NOTE: Requires self[attr] and values to be sequence type and the former should specifically be a list. NrÓ)rrÉr¨rŒrrrrÛÕs  zElement.append_attr_listcCs>t| |¡tƒs||g||<t|tƒs.|g}| ||¡dS)a  First, convert both self[attr] and value to a non-string sequence type; if either is not already a sequence, convert it to a list of one element. Then call append_attr_list. NOTE: self[attr] and value both must not be None. N)r8rÄrˆrÛ)rrÉrŒrrrÚcoerce_append_attr_listâs  zElement.coerce_append_attr_listTcCs|s| |¡dkr|||<dS)z‚ If self[attr] does not exist or force is True or omitted, set self[attr] to value, otherwise do nothing. N©rÄ)rrÉrŒÚforcerrrÚ replace_attrñszElement.replace_attrcCs| |¡|k r| ||¡dS)a If attr is an attribute of self, set self[attr] to [self[attr], value], otherwise set self[attr] to value. NOTE: replace is not used by this function and is kept only for compatibility with the other copy functions. N)rÄrÞ©rrÉrŒr^rrrÚcopy_attr_convertúszElement.copy_attr_convertcCsH| |¡|k rDt| |¡tƒs(t|tƒr6| ||¡n| |||¡dS)a— If attr is an attribute of self and either self[attr] or value is a list, convert all non-sequence values to a sequence of 1 element and then concatenate the two sequence, setting the result to self[attr]. If both self[attr] and value are non-sequences and replace is True or self[attr] is None, replace self[attr] with value. Otherwise, do nothing. N)rÄr8rˆrÞrárârrrÚcopy_attr_coerces ÿzElement.copy_attr_coercecCsH| |¡|k rDt| |¡tƒr6t|tƒr6| ||¡n| |||¡dS)aM If attr is an attribute of self and both self[attr] and value are lists, concatenate the two sequences, setting the result to self[attr]. If either self[attr] or value are non-sequences and replace is True or self[attr] is None, replace self[attr] with value. Otherwise, do nothing. N)rÄr8rˆrÛrárârrrÚcopy_attr_concatenates ÿzElement.copy_attr_concatenatecCs | |¡|k r| |||¡dS)zz If replace is True or self[attr] is None, replace self[attr] with value. Otherwise, do nothing. N)rÄrárârrrÚcopy_attr_consistent$szElement.copy_attr_consistentFcCsRt|tƒr|j}|r|j}n|j}| |¡t||ƒD]}||||||ƒq6dS)a. Updates all attributes from node or dictionary `dict_`. Appends the basic attributes ('ids', 'names', 'classes', 'dupnames', but not 'source') and then, for all other attributes in dict_, updates the same attribute in self. When attributes with the same identifier appear in both self and dict_, the two values are merged based on the value of update_fun. Generally, when replace is True, the values in self are replaced or merged with the values in dict_; otherwise, the values in self may be preserved or merged. When and_source is True, the 'source' attribute is included in the copy. NOTE: When replace is False, and self contains a 'source' attribute, 'source' is not replaced even when dict_ has a 'source' attribute, though it may still be merged into a list depending on the value of update_fun. NOTE: It is easier to call the update-specific methods then to pass the update_fun method to this function. N)r8rr†Úis_not_list_attributeÚis_not_known_attributerÝÚfilter)rrÜZ update_funr^Ú and_sourceZ filter_funr‹rrrÚupdate_all_atts,s  zElement.update_all_attscCs| |tj||¡dS)aC Updates all attributes from node or dictionary `dict_`. Appends the basic attributes ('ids', 'names', 'classes', 'dupnames', but not 'source') and then, for all other attributes in dict_, updates the same attribute in self. When attributes with the same identifier appear in both self and dict_ and replace is True, the values in self are replaced with the values in dict_; otherwise, the values in self are preserved. When and_source is True, the 'source' attribute is included in the copy. NOTE: When replace is False, and self contains a 'source' attribute, 'source' is not replaced even when dict_ has a 'source' attribute, though it may still be merged into a list depending on the value of update_fun. N)rër€ræ©rrÜr^rêrrrÚupdate_all_atts_consistantlyRs ÿz$Element.update_all_atts_consistantlycCs| |tj||¡dS)a Updates all attributes from node or dictionary `dict_`. Appends the basic attributes ('ids', 'names', 'classes', 'dupnames', but not 'source') and then, for all other attributes in dict_, updates the same attribute in self. When attributes with the same identifier appear in both self and dict_ whose values aren't each lists and replace is True, the values in self are replaced with the values in dict_; if the values from self and dict_ for the given identifier are both of list type, then the two lists are concatenated and the result stored in self; otherwise, the values in self are preserved. When and_source is True, the 'source' attribute is included in the copy. NOTE: When replace is False, and self contains a 'source' attribute, 'source' is not replaced even when dict_ has a 'source' attribute, though it may still be merged into a list depending on the value of update_fun. N)rër€rårìrrrÚupdate_all_atts_concatenatinggs ÿz%Element.update_all_atts_concatenatingcCs| |tj||¡dS)a[ Updates all attributes from node or dictionary `dict_`. Appends the basic attributes ('ids', 'names', 'classes', 'dupnames', but not 'source') and then, for all other attributes in dict_, updates the same attribute in self. When attributes with the same identifier appear in both self and dict_ whose values are both not lists and replace is True, the values in self are replaced with the values in dict_; if either of the values from self and dict_ for the given identifier are of list type, then first any non-lists are converted to 1-element lists and then the two lists are concatenated and the result stored in self; otherwise, the values in self are preserved. When and_source is True, the 'source' attribute is included in the copy. NOTE: When replace is False, and self contains a 'source' attribute, 'source' is not replaced even when dict_ has a 'source' attribute, though it may still be merged into a list depending on the value of update_fun. N)rër€rärìrrrÚupdate_all_atts_coercions ÿz Element.update_all_atts_coercioncCs|j|tj|d�dS)a} Updates all attributes from node or dictionary `dict_`. Appends the basic attributes ('ids', 'names', 'classes', 'dupnames', but not 'source') and then, for all other attributes in dict_, updates the same attribute in self. When attributes with the same identifier appear in both self and dict_ then first any non-lists are converted to 1-element lists and then the two lists are concatenated and the result stored in self; otherwise, the values in self are preserved. When and_source is True, the 'source' attribute is included in the copy. NOTE: When replace is False, and self contains a 'source' attribute, 'source' is not replaced even when dict_ has a 'source' attribute, though it may still be merged into a list depending on the value of update_fun. )rêN)rër€rã)rrÜrêrrrÚupdate_all_atts_convert˜s ÿzElement.update_all_atts_convertcCs g|_dSrr¹rrrrÚclear­sz Element.clearcCsD| |¡}t|tƒr(| |¡|||<n|dk r@||||d…<dS)z8Replace one child `Node` with another child or children.NrF)rJr8rr')rÚoldÚnewrJrrrr^°s     zElement.replacecCs„|}t|tƒs4z |d}Wntk r2d}YnXt|tƒrJ| |¡n(|jD] }||rPtd|||fƒ‚qP|j ||¡dS)zc Replace `self` node with `new`, where `new` is a node or a list of nodes. rNzLosing "%s" attribute: %s) r8rrLr€rÝrÚr³r r^)rróÚupdater‹rrrÚ replace_self¹s       ÿzElement.replace_selfrcCsRt|tƒs|f}t|tt|ƒ|ƒƒD](}|D]}t|||ƒr,|Sq,q$dS)aM Return the index of the first child whose class exactly matches. Parameters: - `childclass`: A `Node` subclass to search for, or a tuple of `Node` classes. If a tuple, any of the classes may match. - `start`: Initial index to check. - `end`: Initial index to *not* check. N)r8ÚtupleÚrangeÚminrH©rZ childclassr´ÚendrJrŸrrrÚfirst_child_matching_classÏs z"Element.first_child_matching_classcCsTt|tƒs|f}t|tt|ƒ|ƒƒD]*}|D]}t|j||ƒr,q$q,|Sq$dS)aI Return the index of the first child whose class does *not* match. Parameters: - `childclass`: A `Node` subclass to skip, or a tuple of `Node` classes. If a tuple, none of the classes may match. - `start`: Initial index to check. - `end`: Initial index to *not* check. N)r8rör÷rørHr0rùrrrÚfirst_child_not_matching_classâs  z&Element.first_child_not_matching_classrcs2d dˆˆ| ¡fg‡‡fdd„|jDƒ¡S)Nr]z%s%s csg|]}| ˆˆd¡‘qS)rF)rr¿©rrrrrxúsÿz#Element.pformat..)r_r r0rrrýrrøs  ÿÿzElement.pformatcCs4|jfd|ji|j—Ž}|j|_|j|_|j|_|S)Nrk)r*rkr†r!r"r$©rÚobjrrrrýs z Element.copycCs"| ¡}| dd„|jDƒ¡|S)NcSsg|] }| ¡‘qSr)rr¿rrrrxsz$Element.deepcopy..)rr:r0)rrrrrrszElement.deepcopycCs2tjdtdd�d|kst‚|d | ¡¡dS)z+Add a new class to the "classes" attribute.zadocutils.nodes.Element.set_class deprecated; append to Element['classes'] list attribute directlyé)Ú stacklevelr�r‚N)ÚwarningsÚwarnÚDeprecationWarningr³r9rŠ©rr§rrrÚ set_class s þ zElement.set_classcCsZd|_t|diƒ |¡}t|diƒ |¡}|r@|dk s:t‚d|_|rV|dk sPt‚d|_dS)zQNote that this Element has been referenced by its name `name` or id `id`.rFZexpect_referenced_by_nameZexpect_referenced_by_idN)Ú referencedÚgetattrrÄr³)rr§ÚidZby_nameZby_idrrrÚnote_referenced_bys  zElement.note_referenced_bycCs ||jkS)z‹ Returns True if and only if the given attribute is NOT one of the basic list attributes defined for all Elements. rÙ©r<rÉrrrrç"szElement.is_not_list_attributecCs ||jkS)zj Returns True if and only if the given attribute is NOT recognized by this class. )Úknown_attributesr rrrrè*szElement.is_not_known_attribute)r])N)N)N)r])rÕ)T)T)TF)TF)TF)F)rr)NN)Hr+rOrPrQrÚZlocal_attributesr‡r rqrÀrmrrVrsr£rRrSr r r¡r¢r©r¬rµr·r¸r¼r½r¾rrÂr•rÄrÊrËrÌZhas_keyrÑr9r:rÔrÖrØrJrÁrÝrÛrÞrárãrärårærërírîrïrðrñr^rõÚmaxsizerûrürrrrr Ú classmethodrçrèrrrrr€�s #              ÿ &ÿ ÿ ÿ   ÿ    r€c@seZdZdZdZddd„ZdS)Ú TextElementaé An element which directly contains text. Its children are all `Text` or `Inline` subclass nodes. You can check whether an element's context is inline simply by checking whether its immediate parent is a `TextElement` instance (including subclasses). This is handy for nodes like `image` that can appear both inline and as standalone body elements. If passing children to `__init__()`, make sure to set `text` to ``''`` or some other suitable value. r]cOs@|dkr(t|ƒ}tj|||f|ž|Žntj||f|ž|ŽdS)Nr])rdr€rm)rrkrar0r†ZtextnoderrrrmEs ÿzTextElement.__init__N)r]r])r+rOrPrQrÀrmrrrrr3s rc@seZdZdZddd„ZdS)ÚFixedTextElementz5An element which directly contains preformatted text.r]cOs$tj|||f|ž|Žd|jd<dS)NÚpreservez xml:space)rrmr†)rrkrar0r†rrrrmRszFixedTextElement.__init__N)r]r])r+rOrPrQrmrrrrrNsrc@seZdZdZdS)Ú ResolvablerN)r+rOrPZresolvedrrrrr[src@seZdZdd„ZdS)Ú BackLinkablecCs|d |¡dS)Nr…rÓ)rÚrefidrrrÚ add_backrefbszBackLinkable.add_backrefN)r+rOrPrrrrrr`src@s eZdZdS)ÚRootN©r+rOrPrrrrrjsrc@s eZdZdS)ÚTitularNrrrrrrlsrc@seZdZdZdS)ÚPreBibliographiczd d „Zd?d d „Zd d„Z dd„Z d@dd„Z dAdd„Z dd„Z dd„Zdd„Zdd„Zdd„Zdd „Zd!d"„Zd#d$„Zd%d&„Zd'd(„Zd)d*„Zd+d,„ZdBd-d.„Zd/d0„ZdCd1d2„Zd3d4„Zd5d6„Zd7d8„Zd9d:„Zd;d<„Z dS)Dr!z‚ The document root element. Do not instantiate this class directly; use `docutils.utils.new_document()` instead. cOsÎtj|f|ž|Žd|_d|_||_||_g|_i|_i|_i|_ i|_ i|_ i|_ i|_ i|_i|_g|_g|_g|_g|_g|_g|_d|_d|_d|_g|_g|_ddl}|j |¡|_d|_||_ dS)NrFr)!r€rmr#r%Úsettingsr(Úindirect_targetsÚsubstitution_defsÚsubstitution_namesÚrefnamesÚrefidsÚnameidsÚ nametypesr�Ú footnote_refsÚ citation_refsÚ autofootnotesÚautofootnote_refsÚsymbol_footnotesÚsymbol_footnote_refsÚ footnotesÚ citationsZautofootnote_startZsymbol_footnote_startÚid_startÚparse_messagesÚtransform_messagesZdocutils.transformsZ transformsZ TransformerÚ transformerÚ decorationr!)rr)r(ÚargsÚkwargsZdocutilsrrrrm§s<zdocument.__init__cCs|j ¡}d|d<d|d<|S)zB Return dict with unpicklable references removed. Nr(r<)Ú__dict__r)rÚstaterrrÚ __getstate__s zdocument.__getstate__NcCs6|dkrddlmm}| ¡}| | |¡¡|S)z-Return a DOM representation of this document.Nr)r rrrr–rrrrrr s zdocument.asdomcCsÖ|dD]<}||jkr|j||k r|j d|¡}|dkr||7}q|dsÈ|dD]&}|jjt|ƒ}|rV||jkrVqºqVd}|r�||jkrº|jj|jjt|jƒ}|jd7_q‚|d  |¡||j|<|S)Nr�zDuplicate ID: "%s".rƒr]rF) r�r(Zseverer)Z id_prefixÚmake_idZauto_id_prefixr r9r9)rr?Úmsgnoder Úmsgr§rrrÚset_ids*   ÿÿ zdocument.set_idcCsD|dD]6}||jkr*| |||||¡q||j|<||j|<qdS)aÝ `self.nameids` maps names to IDs, while `self.nametypes` maps names to booleans representing hyperlink type (True==explicit, False==implicit). This method updates the mappings. The following state transition table shows how `self.nameids` ("ids") and `self.nametypes` ("types") change with new input (a call to this method), and what actions are performed ("implicit"-type system messages are INFO/1, and "explicit"-type system messages are ERROR/3): ==== ===== ======== ======== ======= ==== ===== ===== Old State Input Action New State Notes ----------- -------- ----------------- ----------- ----- ids types new type sys.msg. dupname ids types ==== ===== ======== ======== ======= ==== ===== ===== - - explicit - - new True - - implicit - - new False None False explicit - - new True old False explicit implicit old new True None True explicit explicit new None True old True explicit explicit new,old None True [#]_ None False implicit implicit new None False old False implicit implicit new,old None False None True implicit implicit new None True old True implicit implicit new old True ==== ===== ======== ======== ======= ==== ===== ===== .. [#] Do not clear the name-to-id map or invalidate the old target if both old and new targets are external and refer to identical URIs. The new target is invalidated regardless. rƒN)r/Úset_duplicate_name_idr0)rr?r rDÚexplicitr§rrrÚset_name_id_map&s   zdocument.set_name_id_mapc Csf|j|}|j|}|p||j|<|rê|rÂd}|dk rŒ|j|} d|krp|d} | drpd| krp| d| krpd}|dkrŒt| |ƒd|j|<|jj|d||g|d�} |dkr¶|| 7}t||ƒn&||j|<|dk rè|j|} t| |ƒn8|dk �r|�sd|j|<|j|} t| |ƒt||ƒ|�r8|�sb|dk �rb|jjd||g|d�} |dk�rb|| 7}dS)NrÚrefurirƒrFz%Duplicate explicit target name: "%s".)r…Ú base_nodez%Duplicate implicit target name: "%s".)r/r0r�Údupnamer(Úsystem_messageÚinfo) rr?r r§rDrHZold_idZ old_explicitrZold_noderJrErrrrGMsZ   ÿ þ  þ        þ zdocument.set_duplicate_name_idcCs ||jkSr)r/rrrrÚhas_namewszdocument.has_namecCs"| ||¡}|j|||dd�dS)N©rH©rFrI©rÚtargetrDr rrrÚnote_implicit_target{s zdocument.note_implicit_targetcCs"| ||¡}|j|||dd�dS)NTrPrQrRrrrÚnote_explicit_targets zdocument.note_explicit_targetcCs|j |dg¡ |¡dS©NÚrefname)r-rÌr9©rr?rrrÚ note_refnameƒszdocument.note_refnamecCs|j |dg¡ |¡dS)Nr)r.rÌr9rXrrrÚ note_refid†szdocument.note_refidcCs"|j |¡|dr| |¡dS)Nrƒ)r*r9rY©rrSrrrÚnote_indirect_target‰s zdocument.note_indirect_targetcCs| |¡dSr)rFr[rrrÚnote_anonymous_targetŽszdocument.note_anonymous_targetcCs| |¡|j |¡dSr)rFr3r9©rÚfootnoterrrÚnote_autofootnote‘s zdocument.note_autofootnotecCs| |¡|j |¡dSr)rFr4r9©rÚrefrrrÚnote_autofootnote_ref•s zdocument.note_autofootnote_refcCs| |¡|j |¡dSr)rFr5r9r^rrrÚnote_symbol_footnote™s zdocument.note_symbol_footnotecCs| |¡|j |¡dSr)rFr6r9rarrrÚnote_symbol_footnote_ref�s z!document.note_symbol_footnote_refcCs| |¡|j |¡dSr)rFr7r9r^rrrÚ note_footnote¡s zdocument.note_footnotecCs0| |¡|j |dg¡ |¡| |¡dSrV)rFr1rÌr9rYrarrrÚnote_footnote_ref¥s zdocument.note_footnote_refcCs|j |¡dSr)r8r9)rÚcitationrrrÚ note_citationªszdocument.note_citationcCs0| |¡|j |dg¡ |¡| |¡dSrV)rFr2rÌr9rYrarrrÚnote_citation_ref­s zdocument.note_citation_refcCsft|ƒ}||jkrJ|jjd||d�}|dkr6||7}|j|}t||ƒ||j|<||jt|ƒ<dS)Nz-Duplicate substitution definition name: "%s".)rK)Úwhitespace_normalize_namer+r(ÚerrorrLr,Úfully_normalize_name)rZsubdefZdef_namerDr§rEZoldnoderrrÚnote_substitution_def²s þ   zdocument.note_substitution_defcCst|ƒ|d<dSrV)rk)rZsubrefrWrrrÚnote_substitution_refÁszdocument.note_substitution_refcCs|j ||¡dSr)r<Z add_pending)rÚpendingÚpriorityrrrÚ note_pendingÄszdocument.note_pendingcCs|j |¡dSr)r:r9©rÚmessagerrrÚnote_parse_messageÇszdocument.note_parse_messagecCs|j |¡dSr)r;r9rsrrrÚnote_transform_messageÊszdocument.note_transform_messagecCs$||_|dkr||_n |d|_dSrU)r#r%)rr"ÚoffsetrrrÚ note_sourceÍszdocument.note_sourcecCs*|j|j|jf|jŽ}|j|_|j|_|Sr)r*r)r(r†r"r$rþrrrrÔs ÿz document.copycCsB|js + internal attributes Use `document.note_pending()` so that the `docutils.transforms.Transformer` stage of processing can run all pending transforms. Nr]cOs(tj||f|ž|Ž||_|p i|_dSr)r€rmÚ transformÚdetails)rrÈrÉrkr0r†rrrrmÌs zpending.__init__rrcs dd|jj|jjfdg}t|j ¡ƒ}| ¡|D]¬\}}t|tƒrv|  dd|f¡|  dd„|  ¡  ¡Dƒ¡q4|rÌt|tƒrÌt|dtƒrÌ|  dd|f¡|D] }|  d d„|  ¡  ¡Dƒ¡q¨q4|  d d||f¡q4t   |ˆˆ¡d ‡‡fd d„|Dƒ¡S) Nz.. internal attributes:z .transform: %s.%sz .details:z%7s%s:r]cSsg|]}dd|f‘qS©z%9s%sr]rrurrrrxâsÿz#pending.pformat..rcSsg|]}dd|f‘qSrÊrrurrrrxèsÿz %7s%s: %rcsg|]}dˆˆ|f‘qS)z %s%s rrurýrrrxísÿ)rÈrOr+rˆrÉr‰rÃr8rr9r:rrzr€r_)rrrZ internalsrÉr«rŒr“rrýrr×s8ÿü    ÿ  ÿ  ÿ  ÿÿzpending.pformatcCs6|j|j|j|jf|jŽ}|j|_|j|_|j|_|Sr)r*rÈrÉrkr†r!r"r$rþrrrrðsÿz pending.copy)Nr])rr)r+rOrPrQrmrrrrrrrp°s ÿ rpc@seZdZdZdS)Úrawz@ Raw data that is to be passed untouched to the Writer. NrrrrrrËùsrËc@s eZdZdS)ÚemphasisNrrrrrrÌsrÌc@s eZdZdS)ÚstrongNrrrrrrÍsrÍc@s eZdZdS)ÚliteralNrrrrrrÎsrÎc@s eZdZdS)Ú referenceNrrrrrrÏ srÏc@s eZdZdS)Úfootnote_referenceNrrrrrrÐ srÐc@s eZdZdS)Úcitation_referenceNrrrrrrÑ srÑc@s eZdZdS)Úsubstitution_referenceNrrrrrrÒ srÒc@s eZdZdS)Útitle_referenceNrrrrrrÓ srÓc@s eZdZdS)Ú abbreviationNrrrrrrÔsrÔc@s eZdZdS)ÚacronymNrrrrrrÕsrÕc@s eZdZdS)Ú superscriptNrrrrrrÖsrÖc@s eZdZdS)Ú subscriptNrrrrrr×sr×c@s eZdZdS)ÚmathNrrrrrrØsrØc@seZdZdd„ZdS)ÚimagecCs | dd¡S)NZaltr]rßrrrrrsz image.astextNr¤rrrrrÙsrÙc@s eZdZdS)ÚinlineNrrrrrrÚsrÚc@s eZdZdS)Ú problematicNrrrrrrÛsrÛc@s eZdZdS)Ú generatedNrrrrrrÜsrÜa< Text abbreviation acronym address admonition attention attribution author authors block_quote bullet_list caption caution citation citation_reference classifier colspec comment compound contact container copyright danger date decoration definition definition_list definition_list_item description docinfo doctest_block document emphasis entry enumerated_list error field field_body field_list field_name figure footer footnote footnote_reference generated header hint image important inline label legend line line_block list_item literal literal_block math math_block note option option_argument option_group option_list option_list_item option_string organization paragraph pending problematic raw reference revision row rubric section sidebar status strong subscript substitution_definition substitution_reference subtitle superscript system_message table target tbody term tgroup thead tip title title_reference topic transition version warningc@s<eZdZdZdZdd„Zdd„Zdd„Zd d „Zd d „Z d S)Ú NodeVisitoraŠ "Visitor" pattern [GoF95]_ abstract superclass implementation for document tree traversals. Each node class has corresponding methods, doing nothing by default; override individual methods for specific and useful behaviour. The `dispatch_visit()` method is called by `Node.walk()` upon entering a node. `Node.walkabout()` also calls the `dispatch_departure()` method before exiting a node. The dispatch methods call "``visit_`` + node class name" or "``depart_`` + node class name", resp. This is a base class for visitors whose ``visit_...`` & ``depart_...`` methods should be implemented for *all* node types encountered (such as for `docutils.writers.Writer` subclasses). Unimplemented methods will raise exceptions. For sparse traversals, where only certain node types are of interest, subclass `SparseNodeVisitor` instead. When (mostly or entirely) uniform processing is desired, subclass `GenericNodeVisitor`. .. [GoF95] Gamma, Helm, Johnson, Vlissides. *Design Patterns: Elements of Reusable Object-Oriented Software*. Addison-Wesley, Reading, MA, USA, 1995. rcCs ||_dSr)r!©rr!rrrrmjszNodeVisitor.__init__cCs:|jj}t|d||jƒ}|jj d|j|f¡||ƒS)zª Call self."``visit_`` + node class name" with `node` as parameter. If the ``visit_...`` method does not exist, call self.unknown_visit. Úvisit_z;docutils.nodes.NodeVisitor.dispatch_visit calling %s for %s)r*r+rÚ unknown_visitr!r(r)©rr?Z node_nameÚmethodrrrr,msÿÿzNodeVisitor.dispatch_visitcCs:|jj}t|d||jƒ}|jj d|j|f¡||ƒS)z° Call self."``depart_`` + node class name" with `node` as parameter. If the ``depart_...`` method does not exist, call self.unknown_departure. Údepart_z?docutils.nodes.NodeVisitor.dispatch_departure calling %s for %s)r*r+rÚunknown_departurer!r(r)rárrrr7zsÿÿzNodeVisitor.dispatch_departurecCs2|jjjs|jj|jkr.td|j|jjfƒ‚dS)zk Called when entering unknown `Node` types. Raise an exception unless overridden. z!%s visiting unknown node type: %sN©r!r)Zstrict_visitorr*r+ÚoptionalrrXrrrrà‡s  ÿ ÿÿzNodeVisitor.unknown_visitcCs2|jjjs|jj|jkr.td|j|jjfƒ‚dS)zi Called before exiting unknown `Node` types. Raise exception unless overridden. z"%s departing unknown node type: %sNrårXrrrrä“s  ÿ ÿÿzNodeVisitor.unknown_departureN) r+rOrPrQrærmr,r7ràrärrrrrÝCs    rÝc@seZdZdZdS)ÚSparseNodeVisitora Base class for sparse traversals, where only certain node types are of interest. When ``visit_...`` & ``depart_...`` methods should be implemented for *all* node types (such as for `docutils.writers.Writer` subclasses), subclass `NodeVisitor` instead. Nrrrrrrç srçc@s eZdZdZdd„Zdd„ZdS)ÚGenericNodeVisitora˜ Generic "Visitor" abstract superclass, for simple traversals. Unless overridden, each ``visit_...`` method calls `default_visit()`, and each ``depart_...`` method (when using `Node.walkabout()`) calls `default_departure()`. `default_visit()` (and `default_departure()`) must be overridden in subclasses. Define fully generic visitors by overriding `default_visit()` (and `default_departure()`) only. Define semi-generic visitors by overriding individual ``visit_...()`` (and ``depart_...()``) methods also. `NodeVisitor.unknown_visit()` (`NodeVisitor.unknown_departure()`) should be overridden for default behavior. cCst‚dS©z)Override for generic, uniform traversals.NrrXrrrÚ default_visit¼sz GenericNodeVisitor.default_visitcCst‚dSrérrXrrrÚdefault_departureÀsz$GenericNodeVisitor.default_departureN)r+rOrPrQrêrërrrrrèªsrècCs| |¡dSr)rêrXrrrÚ_call_default_visitÄsrìcCs| |¡dSr)rërXrrrÚ_call_default_departureÇsrícCsdSrrrXrrrÚ_nopÊsrîcCsN|D]D}ttd|tƒttd|tƒttd|tƒttd|tƒqdS)z%Save typing with dynamic assignments:rßrãN)Úsetattrrèrìrírçrî)rƒÚ_namerrrÚ_add_node_class_namesÍs rñc@s0eZdZdZdd„Zdd„Zdd„Zdd „Zd S) ÚTreeCopyVisitorzQ Make a complete copy of a tree or branch, including element attributes. cCst ||¡g|_g|_dSr)rèrmÚ parent_stackr rÞrrrrmÞs zTreeCopyVisitor.__init__cCs |jdSrˆ)r rrrrÚ get_tree_copyãszTreeCopyVisitor.get_tree_copycCs,| ¡}|j |¡|j |j¡||_dS)z9Copy the current node, and make it the new acting parent.N)rr r9ró)rr?Znewnoderrrrêæs zTreeCopyVisitor.default_visitcCs|j ¡|_dS)z#Restore the previous acting parent.N)rórÖr rXrrrrëísz!TreeCopyVisitor.default_departureN)r+rOrPrQrmrôrêrërrrrròØs ròc@seZdZdZdS)ÚTreePruningExceptionz÷ Base class for `NodeVisitor`-related tree pruning exceptions. Raise subclasses from within ``visit_...`` or ``depart_...`` methods called from `Node.walk()` and `Node.walkabout()` tree traversals to prune the tree traversed. Nrrrrrrõòsrõc@seZdZdZdS)r-z… Do not visit any children of the current node. The current node's siblings and ``depart_...`` method are not affected. Nrrrrrr-ÿsr-c@seZdZdZdS)r2z� Do not visit any more siblings (to the right) of the current node. The current node's children and its ``depart_...`` method are not affected. Nrrrrrr2 sr2c@seZdZdZdS)r.zq Do not visit the current node's children, and do not call the current node's ``depart_...`` method. Nrrrrrr.sr.c@seZdZdZdS)r/z Do not call the current node's ``depart_...`` method. The current node's children and siblings are not affected. Nrrrrrr/sr/c@seZdZdZdS)Ú NodeFoundz¥ Raise to indicate that the target of a search has been found. This exception must be caught by the client; it is not caught by the traversal code. Nrrrrrrö'sröc@seZdZdZdS)r3a= Stop the traversal alltogether. The current node's ``depart_...`` method is not affected. The parent nodes ``depart_...`` methods are also called as usual. No other nodes are visited. This is an alternative to NodeFound that does not cause exception handling to trickle up to the caller. Nrrrrrr32sr3cCsr| ¡}t|tƒs| ¡}| t¡}| t¡}t d|¡  dd¡ d¡}t   dd  |  ¡¡¡}t  d|¡}t|ƒS)aû Convert `string` into an identifier and return it. Docutils identifiers will conform to the regular expression ``[a-z](-?[a-z0-9]+)*``. For CSS compatibility, identifiers (the "class" and "id" attributes) should have no underscores, colons, or periods. Hyphens may be used. - The `HTML 4.01 spec`_ defines identifiers based on SGML tokens: ID and NAME tokens must begin with a letter ([A-Za-z]) and may be followed by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), and periods ("."). - However the `CSS1 spec`_ defines identifiers based on the "name" token, a tighter interpretation ("flex" tokenizer notation; "latin1" and "escape" 8-bit characters have been replaced with entities):: unicode \[0-9a-f]{1,4} latin1 [¡-ÿ] escape {unicode}|\[ -~¡-ÿ] nmchar [-a-z0-9]|{latin1}|{escape} name {nmchar}+ The CSS1 "nmchar" rule does not include underscores ("_"), colons (":"), or periods ("."), therefore "class" and "id" attributes should not contain these characters. They should be replaced with hyphens ("-"). Combined with HTML's requirements (the first character must be a letter; no "unicode", "latin1", or "escape" characters), this results in the ``[a-z](-?[a-z0-9]+)*`` pattern. .. _HTML 4.01 spec: http://www.w3.org/TR/html401 .. _CSS1 spec: http://www.w3.org/TR/REC-CSS1 ZNFKDrWÚignoreú-r�r])rŠr8r ÚdecodeÚ translateÚ_non_id_translate_digraphsÚ_non_id_translateÚ unicodedataÚ normalizer Ú _non_id_charsÚsubr_r`Ú_non_id_at_ends)Ústringr rrrrC?s#    ÿÿ rCz [^a-z0-9]+z ^[-0-9]+|-+$ÚoÚdÚhr×ÚlÚtÚbrŸÚfÚkržrÇÚyÚzÚgÚjrYÚeÚqrK)!éøii'i1iBigi€iƒiˆiŒi’i™išiži¥i«i­i´i¶iåi%i4i5i6i7i<i?i@iGiIiKiMiOÚszZaeZoeÚdbZqp)éßéæiSi8i9cCs&|d |¡|d |¡d|_dS)Nr„rƒrF)r9rØr)r?r§rrrrL�srLcCsd | ¡ ¡¡S)z.Return a case- and whitespace-normalized name.r�)r_rŠr`©r§rrrrm¤srmcCsd | ¡¡S)z$Return a whitespace-normalized name.r�)r_r`rrrrrk¨srkcCs| dd¡ dd¡S)zDEscape string values that are elements of a list, for serialization.r\z\\r�z\ )r^©rŒrrrr‘¬sr‘cCsd|S)zQuote attributes for pseudo-xmlz"%s"rrrrrr¤°sr¤)FF)¤rQZ __docformat__rRÚosÚrerÚtypesrýÚobjectrrSr rTrZrcrdr€rrrrrrrrrrrrr r!r"r#r$r%r&r'r(r!rzr{r|r}r~rr€r�r‚rƒr„r…r†r‡r=r‰r‹r�rŽr�r�r‘r’r“r”r•r–r—r˜r™ršr›rœr�ržrŸr r¢r¥r¦r§r¨r©rªr«r¬r­r$r®r¯r°r±r²rlr³r´rµr¶r·r¸r¹rºrSr_rhr»r¼r½r¾r¿rÀrÁrÂrÃrÄrÅrMrprËrÌrÍrÎrÏrÐrÑrÒrÓrÔrÕrÖr×rØrÙrÚrÛrÜr`Znode_class_namesrÝrçrèrìrírîrñròÚ Exceptionrõr-r2r.r/rör3rCÚcompilerÿrrürûrLrmrkr‘r¤rrrrÚsž  K   N I ]            1  ß$û