Your IP : 3.135.215.149


Current Path : /opt/alt/python310/lib64/python3.10/__pycache__/
Upload File :
Current File : //opt/alt/python310/lib64/python3.10/__pycache__/_markupbase.cpython-310.opt-1.pyc

o

6��f=9�@sVdZddlZe�d�jZe�d�jZe�d�Ze�d�Ze�d�Z[Gdd	�d	�Z	dS)
z�Shared support for scanning document type declarations in HTML and XHTML.

This module is used as a foundation for the html.parser module.  It has no
documented public API and should not be used directly.

�Nz[a-zA-Z][-_.a-zA-Z0-9]*\s*z(\'[^\']*\'|"[^"]*")\s*z--\s*>z	]\s*]\s*>z]\s*>c@s�eZdZdZdd�Zdd�Zdd�Zdd	�Zd
Zdd�Z	d!dd�Z
d!dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zd S)"�
ParserBaseziParser base class which provides some common support methods used
    by the SGML/HTML and XHTML parsers.cCs|jtur	td��dS)Nz)_markupbase.ParserBase must be subclassed)�	__class__r�RuntimeError��self�r�2/opt/alt/python310/lib64/python3.10/_markupbase.py�__init__s

��zParserBase.__init__cCsd|_d|_dS)N�r��lineno�offsetrrrr�reset s
zParserBase.resetcCs|j|jfS)z&Return current line number and offset.rrrrr�getpos$szParserBase.getposcCsd||kr|S|j}|�d||�}|r(|j||_|�d||�}||d|_|S|j|||_|S)N�
r
)�rawdata�countr�rindexr
)r�i�jrZnlines�posrrr�	updatepos,s�zParserBase.updatepos�c
Cs�|j}|d}|||d�dkr|dS|||d�dvr!dSt|�}|||d�dkr4|�|�S||dkr?|�|�S|�||�\}}|dkrM|S|d	krTd
|_||kr�||}|dkr~||d|�}|d	kru|�|�|dS|�|�|dS|dvr�t||�}|s�dS|�	�}n>|dvr�|�||�\}	}n1||jvr�|d}n'|dkr�|d	kr�|�
|d|�}n|d
vr�td|��td��td||��|dkr�|S||ksXdS)N�r
�>)�-r���z--�[rZdoctyperz"'Z4abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ>Zlinktype�element�link�attlistz&unsupported '[' char in %s declarationz"unexpected '[' char in declarationz!unexpected %r char in declaration)r�len�
parse_comment�parse_marked_section�
_scan_name�_decl_othercharsZhandle_decl�unknown_decl�_declstringlit_match�end�_parse_doctype_subset�AssertionError)
rrrr�nZdecltype�c�data�m�namerrr�parse_declaration<sZ



�



�'zParserBase.parse_declarationr
cCs�|j}|�|d|�\}}|dkr|S|dvr t�||d�}n|dvr-t�||d�}ntd||d|���|s=dS|rO|�d�}|�||d|��|�d�S)N�r>�ignoreZcdataZrcdataZtempZinclude>Zendif�if�elsez+unknown status keyword %r in marked sectionr)	rr$�_markedsectionclose�search�_msmarkedsectioncloser*�startr&r()rr�reportrZsectNamer�matchrrrr#�s"�

zParserBase.parse_marked_sectioncCsh|j}|||d�dkrtd��t�||d�}|sdS|r/|�d�}|�||d|��|�d�S)N��<!--z"unexpected call to parse_comment()rr)rr*�
_commentcloser6r8Zhandle_commentr()rrr9rr:rrrrr"�s

zParserBase.parse_commentc
Cs|j}t|�}|}||k�r||}|dkr�|||d�}|dkr$dS|dkr6|�||d�td|��|d|kr>dS|d|krFdS|||d�dkr^|j|d	d
�}|d	kr]|Sq	|�|d|�\}}|dkrndS|dvr�|�||d�td|��t|d
|�}	|	||�}|d	kr�|Snt|dkr�|d|kr�dS|�|d|�\}}|d	kr�|S||dkr�|d}nM|dkr�|d}||kr�||��r�|d}||kr�||��s�||kr�||dkr�|S|�||�td��dS|��r�|d}n|�||�td|��||ksdS)N�<rrz<!r
z*unexpected char in internal subset (in %r)r;r<r)r9>ZentityrZnotationr z)unknown declaration %r in internal subsetZ_parse_doctype_�%�;�]rz%unexpected char after internal subsetz%unexpected char %r in internal subset)rr!rr*r"r$�getattr�isspace)
rr�declstartposrr+rr,�sr/Zmethrrrr)�s|
��
���
�?z ParserBase._parse_doctype_subsetcCsF|�||�\}}|dkrdS|j}d||d�vr!|�d|�dSdS)Nrrr
)r$r�find)rrrDr/rrrrr�_parse_doctype_element�sz!ParserBase._parse_doctype_elementcCs�|j}|�||�\}}|||d�}|dkrdS|dkr!|dS	|�||�\}}|dkr0|S|||d�}|dkr>dS|dkrvd||d�vrS|�d|�d}ndS|||d���rm|d}|||d���s_||d�sudSn|�||�\}}|||d�}|s�dS|dvr�t||�}|r�|��}ndS|||d�}|s�dS|d	kr�||d�d	kr�dS|�|d|�\}}|dkr�|S|||d�}|s�dS|dkr�|dSq")
Nr
rrrr�(�)�'"�#)rr$rFrCr'r()rrrDrr/rr,r.rrr�_parse_doctype_attlists`��

�z!ParserBase._parse_doctype_attlistcCs�|�||�\}}|dkr|S|j}	|||d�}|sdS|dkr&|dS|dvr8t||�}|s3dS|��}n|�||�\}}|dkrF|Sq)Nrr
rrrJ)r$rr'r()rrrDr/rrr,r.rrr�_parse_doctype_notation=s&

�z"ParserBase._parse_doctype_notationcCs�|j}|||d�dkr*|d}	|||d�}|sdS|��r'|d}nnqn|}|�||�\}}|dkr:|S	|j||d�}|sHdS|dvrZt||�}|rX|��}ndS|dkrb|dS|�||�\}}|dkrp|Sq;)Nr
r?rrrJr)rrCr$r'r()rrrDrrr,r/r.rrr�_parse_doctype_entityTs>
�

�z ParserBase._parse_doctype_entitycCs�|j}t|�}||kr
dSt||�}|r.|��}|��}|t|�|kr&dS|��|��fS|�||�td|||d���)N)Nrzexpected name token at %r�)	rr!�_declname_match�group�strip�lowerr(rr*)rrrDrr+r.rEr/rrrr$xs
�zParserBase._scan_namecCsdS)Nr)rr-rrrr&�szParserBase.unknown_declN)r
)�__name__�
__module__�__qualname__�__doc__r	rrrr%r0r#r"r)rGrLrMrNr$r&rrrrrs"

Q
F9$r)
rW�re�compiler:rPr'r=r5r7rrrrr�<module>s




?>