관리-도구
편집 파일: base.cpython-39.opt-1.pyc
a ����[��f�8����������������������@���s����d�dl�mZmZmZ�d�dlmZ�ddlmZmZm Z �dZ ee�dfeee d�dfhB��dfeee d�d fe d�d fhB��dfee d�dfe d�dfg�dfee d�dfe d�d fg�dfd�ZG�dd��de �ZG�dd��de�ZG�dd��de �ZdS�)�����)�absolute_import�division�unicode_literals)� text_type����)�scopingElements�tableInsertModeElements� namespacesNF�html�buttonZolZul�table�optgroup�optionT)Nr����listr���Zselectc�������������������@���sb���e�Zd�ZdZdd��Zdd��Zdd��Zdd ��Zddd�Zd d��Z dd��Z dd��Zdd��Zdd��Z d S�)�NodezRepresents an item in the treec�����������������C���s(���||�_�d|�_d|�_i�|�_g�|�_g�|�_dS�)zRCreates a Node :arg name: The tag name associated with the node N)�name�parent�value� attributes� childNodesZ_flags)�selfr�����r����J/usr/lib/python3.9/site-packages/pip/_vendor/html5lib/treebuilders/base.py�__init__���s����z Node.__init__c�����������������C���s:���d��dd��|�j���D���}|r,d|�j|f�S�d|�j�S�d�S�)N� c�����������������S���s���g�|�]\}}d�||f��qS�)z%s="%s"r���)�.0r���r���r���r���r���� <listcomp>.���s����z Node.__str__.<locals>.<listcomp>z<%s %s>�<%s>)�joinr����itemsr���)r���Z attributesStrr���r���r����__str__-���s���� �zNode.__str__c�����������������C���s ���d|�j��S�)Nr���)r����r���r���r���r����__repr__6���s����z Node.__repr__c�����������������C���s���t��dS�)z[Insert node as a child of the current node :arg node: the node to insert N��NotImplementedError�r����noder���r���r����appendChild9���s����zNode.appendChildNc�����������������C���s���t��dS�)aB��Insert data as text in the current node, positioned before the start of node insertBefore or to the end of the node's text. :arg data: the data to insert :arg insertBefore: True if you want to insert the text before the node and False if you want to insert it after the node Nr#���)r����data�insertBeforer���r���r���� insertTextA���s���� zNode.insertTextc�����������������C���s���t��dS�)a��Insert node as a child of the current node, before refNode in the list of child nodes. Raises ValueError if refNode is not a child of the current node :arg node: the node to insert :arg refNode: the child node to insert the node before Nr#���)r���r&���ZrefNoder���r���r���r)���M���s���� zNode.insertBeforec�����������������C���s���t��dS�)zhRemove node from the children of the current node :arg node: the child node to remove Nr#���r%���r���r���r����removeChildY���s����zNode.removeChildc�����������������C���s ���|�j�D�]}|�|��qg�|�_�dS�)z�Move all the children of the current node to newParent. This is needed so that trees that don't store text as nodes move the text in the correct way :arg newParent: the node to move all this node's children to N)r���r'���)r���Z newParent�childr���r���r����reparentChildrena���s���� zNode.reparentChildrenc�����������������C���s���t��dS�)z�Return a shallow copy of the current node i.e. a node with the same name and attributes but with no parent or child nodes Nr#���r!���r���r���r���� cloneNoden���s����zNode.cloneNodec�����������������C���s���t��dS�)zFReturn true if the node has children or text, false otherwise Nr#���r!���r���r���r���� hasContentt���s����zNode.hasContent)N)�__name__� __module__�__qualname__�__doc__r���r ���r"���r'���r*���r)���r+���r-���r.���r/���r���r���r���r���r������s��� r���c�������������������@���s���e�Zd�Zdd��Zdd��ZdS�)�ActiveFormattingElementsc�����������������C���sf���d}|t�krV|�d�d�d��D�]:}|t�kr*�qV|��||�r>|d7�}|dkr|��|���qVqt�|�|��d�S�)Nr��������������)�Marker� nodesEqual�remover����append)r���r&���Z equalCount�elementr���r���r���r;���{���s���� zActiveFormattingElements.appendc�����������������C���s$���|j�|j�ksdS�|j|jks dS�dS�)NFT)� nameTupler���)r���Znode1Znode2r���r���r���r9�������s ����z#ActiveFormattingElements.nodesEqualN)r0���r1���r2���r;���r9���r���r���r���r���r4���z���s��� r4���c�������������������@���s����e�Zd�ZdZdZdZdZdZdZdd��Z dd��Z d+dd�Zd d ��Zdd��Z d d��Zdd��Zdd��Zd,dd�Zdd��Zdd��Zdd��Zeee�Zdd��Zdd��Zd-dd �Zd!d"��Zd.d#d$�Zd%d&��Zd'd(��Zd)d*��ZdS�)/�TreeBuildera��Base treebuilder implementation * documentClass - the class to use for the bottommost node of a document * elementClass - the class to use for HTML Elements * commentClass - the class to use for comments * doctypeClass - the class to use for doctypes Nc�����������������C���s���|rd|�_�nd|�_�|�����dS�)zmCreate a TreeBuilder :arg namespaceHTMLElements: whether or not to namespace HTML elements zhttp://www.w3.org/1999/xhtmlN)�defaultNamespace�reset)r���ZnamespaceHTMLElementsr���r���r���r�������s����zTreeBuilder.__init__c�����������������C���s.���g�|�_�t��|�_d�|�_d�|�_d|�_|����|�_d�S�)NF)�openElementsr4����activeFormattingElementsZheadPointerZformPointer�insertFromTable� documentClass�documentr!���r���r���r���r@�������s����zTreeBuilder.resetc�����������������C���s~���t�|d�}|s$t|t�r$td�|f}t|�\}}t|�j�D�]>}|rP||krP�dS�|sd|j|krd�dS�||j|v�A�r:�dS�q:d�S�)Nr=���r ���TF)�hasattr� isinstancer���r ����listElementsMap�reversedrA���r=���)r����targetZvariantZ exactNodeZlistElements�invertr&���r���r���r����elementInScope����s���� zTreeBuilder.elementInScopec�����������������C���s����|�j�s d�S�t|�j��d�}|�j�|�}|tks4||�jv�r8d�S�|tkrl||�jvrl|dkrXd}ql|d8�}|�j�|�}q8|d7�}|�j�|�}|���}|��d|j|j|jd��}||�j�|<�||�j�d�krlq�qld�S�)Nr6���r���r5���ZStartTag)�typer���� namespacer(���) rB����lenr8���rA���r.���� insertElementr���rN���r���)r����i�entryZcloner<���r���r���r����#reconstructActiveFormattingElements����s.���� � z/TreeBuilder.reconstructActiveFormattingElementsc�����������������C���s(���|�j����}|�j�r$|tkr$|�j����}q d�S��N)rB����popr8���)r���rR���r���r���r����clearActiveFormattingElements��s���� z)TreeBuilder.clearActiveFormattingElementsc�����������������C���s:���|�j�ddd��D�]$}|tkr"�q6q|j|kr|��S�qdS�)z�Check if an element exists between the end of the active formatting elements and the last marker. If it does, return it, else return falseNr5���F)rB���r8���r���)r���r����itemr���r���r����!elementInActiveFormattingElements ��s���� z-TreeBuilder.elementInActiveFormattingElementsc�����������������C���s&���|���|�}|�j�|��|�j�|��d�S�rT���)� createElementrA���r;���rE���r'���)r����tokenr<���r���r���r���� insertRoot��s���� zTreeBuilder.insertRootc�����������������C���s6���|d�}|d�}|d�}|���|||�}|�j�|��d�S�)Nr����publicId�systemId)�doctypeClassrE���r'���)r���rZ���r���r\���r]���Zdoctyper���r���r���� insertDoctype ��s ����zTreeBuilder.insertDoctypec�����������������C���s*���|d�u�r|�j�d�}|�|��|d����d�S�)Nr5���r(���)rA���r'����commentClass)r���rZ���r���r���r���r���� insertComment(��s���� zTreeBuilder.insertCommentc�����������������C���s0���|d�}|��d|�j�}|��||�}|d�|_|S�)z.Create an element but don't insert it anywherer���rN���r(���)�getr?����elementClassr����r���rZ���r���rN���r<���r���r���r���rY���-��s ���� zTreeBuilder.createElementc�����������������C���s���|�j�S�rT���)�_insertFromTabler!���r���r���r����_getInsertFromTable5��s����zTreeBuilder._getInsertFromTablec�����������������C���s ���||�_�|r|�j|�_n|�j|�_dS�)zsSwitch the function used to insert an element from the normal one to the misnested table one and back againN)re����insertElementTablerP����insertElementNormal)r���r���r���r���r����_setInsertFromTable8��s���� zTreeBuilder._setInsertFromTablec�����������������C���sL���|d�}|��d|�j�}|��||�}|d�|_|�jd��|��|�j�|��|S�)Nr���rN���r(���r5���)rb���r?���rc���r���rA���r'���r;���rd���r���r���r���rh���C��s���� zTreeBuilder.insertElementNormalc�����������������C���s`���|���|�}|�jd�jtvr$|��|�S�|����\}}|du�rD|�|��n|�||��|�j�|��|S�)z-Create an element and insert it into the treer5���N) rY���rA���r���r���rh����getTableMisnestedNodePositionr'���r)���r;���)r���rZ���r<���r���r)���r���r���r���rg���M��s���� zTreeBuilder.insertElementTablec�����������������C���sV���|du�r|�j�d�}|�jr.|�jr:|�j�d�jtvr:|�|��n|����\}}|�||��dS�)zInsert text data.Nr5���)rA���rC���r���r���r*���rj���)r���r(���r���r)���r���r���r���r*���]��s���� ��zTreeBuilder.insertTextc�����������������C���st���d}d}d}|�j�ddd��D�]}|jdkr|}�q4q|rb|jrJ|j}|}ql|�j�|�j��|�d��}n |�j�d�}||fS�)zsGet the foster parent element, and sibling to insert before (or None) when inserting a misnested table nodeNr5���r���r6���r���)rA���r���r����index)r���Z lastTableZfosterParentr)���Zelmr���r���r���rj���l��s ���� � z)TreeBuilder.getTableMisnestedNodePositionc�����������������C���s8���|�j�d�j}|td�v�r4||kr4|�j�����|��|��d�S�)Nr5���)�ddZdtZlir���r ����pZrpZrt)rA���r���� frozensetrU����generateImpliedEndTags)r���Zexcluder���r���r���r���ro������s����� z"TreeBuilder.generateImpliedEndTagsc�����������������C���s���|�j�S�)zReturn the final tree)rE���r!���r���r���r����getDocument���s����zTreeBuilder.getDocumentc�����������������C���s���|�����}|�jd��|��|S�)zReturn the final fragmentr���)� fragmentClassrA���r-���)r����fragmentr���r���r����getFragment���s����zTreeBuilder.getFragmentc�����������������C���s���t��dS�)z�Serialize the subtree of node in the format required by unit tests :arg node: the node from which to start serializing Nr#���r%���r���r���r����testSerializer���s����zTreeBuilder.testSerializer)N)N)N)N)r0���r1���r2���r3���rD���rc���r`���r^���rq���r���r@���rL���rS���rV���rX���r[���r_���ra���rY���rf���ri����propertyrC���rh���rg���r*���rj���ro���rp���rs���rt���r���r���r���r���r>�������s6��� . r>���)Z __future__r���r���r���Zpip._vendor.sixr���Z constantsr���r���r ���r8���rn���rH����objectr���r���r4���r>���r���r���r���r����<module>���s0��� �� �� ���c