U "»ßj½Mã@sÊdZddlZddlZddlZddlmZdgZe d¡Ze d¡Z e d¡Z e d¡Z e d ¡Z e d ¡Z e d ¡Ze d ¡Ze d ¡Ze d¡Ze dej¡Ze d ¡Ze d¡ZGdd„dejƒZdS)zA parser for HTML and XHTML.éN)ÚunescapeÚ HTMLParserz[&<]z &[a-zA-Z#]z%&([a-zA-Z][-.a-zA-Z0-9]*)[^a-zA-Z0-9]z)&#(?:[0-9]+|[xX][0-9a-fA-F]+)[^0-9a-fA-F]z <[a-zA-Z]z z--\s*>z+([a-zA-Z][^\t\n\r\f />\x00]*)(?:\s|/(?!>))*z]((?<=[\'"\s/])[^\s/>][^\s/=>]*)(\s*=+\s*(\'[^\']*\'|"[^"]*"|(?![\'"])[^>\s]*))?(?:\s|/(?!>))*aF <[a-zA-Z][^\t\n\r\f />\x00]* # tag name (?:[\s/]* # optional whitespace before attribute name (?:(?<=['"\s/])[^\s/>][^\s/=>]* # attribute name (?:\s*=+\s* # value indicator (?:'[^']*' # LITA-enclosed value |"[^"]*" # LIT-enclosed value |(?!['"])[^>\s]* # bare value ) \s* # possibly followed by a space )?(?:\s|/(?!>))* )* )? \s* # trailing whitespace z#c@sèeZdZdZdZddœdd„Zdd„Zd d „Zd d „Zd Z dd„Z dd„Z dd„Z dd„Z dd„Zd9dd„Zdd„Zdd„Zdd „Zd!d"„Zd#d$„Zd%d&„Zd'd(„Zd)d*„Zd+d,„Zd-d.„Zd/d0„Zd1d2„Zd3d4„Zd5d6„Zd7d8„Zd S):raEFind tags and other markup and call handler functions. Usage: p = HTMLParser() p.feed(data) ... p.close() Start tags are handled by calling self.handle_starttag() or self.handle_startendtag(); end tags by self.handle_endtag(). The data between tags is passed from the parser to the derived class by calling self.handle_data() with the data as argument (the data may be split up in arbitrary chunks). If convert_charrefs is True the character references are converted automatically to the corresponding Unicode character (and self.handle_data() is no longer split in chunks), otherwise they are passed by calling self.handle_entityref() or self.handle_charref() with the string containing respectively the named or numeric reference as the argument. )ZscriptZstyleT)Úconvert_charrefscCs||_| ¡dS)zÆInitialize and reset this instance. If convert_charrefs is True (the default), all character references are automatically converted to the corresponding Unicode characters. N)rÚreset)Úselfr©rú0/opt/alt/python38/lib64/python3.8/html/parser.pyÚ__init__XszHTMLParser.__init__cCs:d|_d|_t|_d|_g|_d|_d|_tj   |¡dS)z1Reset this instance. Loses all unprocessed data.Úz???Nré) ÚrawdataÚlasttagÚinteresting_normalÚ interestingÚ cdata_elemÚ_pendingÚ _pending_lenÚ_parse_thresholdÚ _markupbaseÚ ParserBaser©rrrr raszHTMLParser.resetcCs®|jt|ƒ7_|j|jkr,|j |¡n~|jsB|j|7_n,|j |¡|jd |j¡7_|j ¡d|_t|jƒ}| d¡t|jƒ|kržd|_n t|jƒ|_dS)z‘Feed data to the parser. Call this as often as you want, with as little or as much text as you want (may include '\n'). r rr N) rÚlenrrÚappendr ÚjoinÚclearÚgoahead)rÚdataÚnrrr Úfeedls      zHTMLParser.feedcCs:|jr,|jd |j¡7_|j ¡d|_| d¡dS)zHandle any buffered data.r rr N)rr rrrrrrrr ÚcloseŠs  zHTMLParser.closeNcCs|jS)z)Return full source of start tag: '<...>'.)Ú_HTMLParser__starttag_textrrrr Úget_starttag_text”szHTMLParser.get_starttag_textcCs$| ¡|_t d|jtj¡|_dS)Nz )ÚlowerrÚreÚcompileÚIr)rÚelemrrr Úset_cdata_mode˜s zHTMLParser.set_cdata_modecCst|_d|_dS©N)rrrrrrr Úclear_cdata_modeœszHTMLParser.clear_cdata_modec Cs2|j}d}t|ƒ}||k�rÂ|jrv|jsv| d|¡}|dkr | dt||dƒ¡}|dkrpt d¡  ||¡sp�qÂ|}n*|j   ||¡}|r’|  ¡}n|jrœ�qÂ|}||krÞ|jrÌ|jsÌ|  t |||…ƒ¡n|  |||…¡| ||¡}||krö�qÂ|j}|d|ƒ�r2t ||¡�r"| |¡} nŒ|d|ƒ�r:| |¡} nt|d|ƒ�rR| |¡} n\|d|ƒ�rj| |¡} nD|d |ƒ�r‚| |¡} n,|d |k�s–|�rÂ|  d¡|d } n�qÂ| dk�r$|�sÂ�qÂt ||¡�rÔ�nL|d|ƒ�r"|d |k�rú|  d¡n&t ||¡�r n| ||d d…¡nþ|d|ƒ�rz|}d D]*} | | |d ¡�r6|t| ƒ8}�qb�q6| ||d |…¡n¦|d|ƒ�rž| ||dd…¡n‚|||d… ¡dk�rÐ| ||d d…¡nP|d |ƒ�rô| ||d d…¡n,|d|ƒ�r| ||d d…¡ntdƒ‚|} | || ¡}q|d|ƒ�rØt ||¡}|�rš|  ¡d d…} | !| ¡| "¡} |d| d ƒ�sŠ| d } | || ¡}qnÚkÚsuffixÚnamerrr r£sä   ÿ                                     zHTMLParser.goaheadcCs¢|j}|||d…dkr$| |¡S|||d…dkrB| |¡S|||d… ¡dkr”| d|d¡}|dkrvdS| ||d |…¡|d S| |¡SdS) Nr1r.r2zÚ r_)r!Úcheck_for_whole_start_tagr Útagfind_tolerantr@rPrNr#rÚattrfind_tolerantrrÚstripZgetposÚcountrr9r=rHÚhandle_startendtagÚhandle_starttagÚCDATA_CONTENT_ELEMENTSr()rrTÚendposr Úattrsr@rVÚtagÚmÚattrnameÚrestZ attrvaluerPÚlinenoÚoffsetrrr rA\sZ   & ÿ ÿ       ÿ    zHTMLParser.parse_starttagcCs¶|j}t ||¡}|rª| ¡}|||d…}|dkr>|dS|dkr~| d|¡rZ|dS| d|¡rjdS||krv|S|dS|dkrŠdS|dkr–dS||kr¢|S|dStd ƒ‚dS) Nr rú/r_r/r6r z6abcdefghijklmnopqrstuvwxyz=/ABCDEFGHIJKLMNOPQRSTUVWXYZr5)r Úlocatestarttagend_tolerantr@rPr>rL)rrTr rlrUÚnextrrr ra�s.   z$HTMLParser.check_for_whole_start_tagcCs|j}t ||d¡}|sdS| ¡}t ||¡}|sÀ|jdk rV| |||…¡|St ||d¡}|s�|||d…dkr†|dS|  |¡S|  d¡  ¡}|  d| ¡¡}|  |¡|dS|  d¡  ¡}|jdk rø||jkrø| |||…¡|S|  |¡| ¡|S)Nr r6r/r2zr)r Ú endendtagr;rPÚ endtagfindr@rr=rbrYrNr#r8Ú handle_endtagr*)rrTr r@rZZ namematchZtagnamer'rrr rB±s6       zHTMLParser.parse_endtagcCs| ||¡| |¡dSr))rgrv©rrkrjrrr rfÙs zHTMLParser.handle_startendtagcCsdSr)rrwrrr rgÞszHTMLParser.handle_starttagcCsdSr)r)rrkrrr rvâszHTMLParser.handle_endtagcCsdSr)r©rrXrrr rOæszHTMLParser.handle_charrefcCsdSr)rrxrrr rRêszHTMLParser.handle_entityrefcCsdSr)r©rrrrr r=îszHTMLParser.handle_datacCsdSr)rryrrr rGòszHTMLParser.handle_commentcCsdSr)r)rZdeclrrr rJöszHTMLParser.handle_declcCsdSr)rryrrr rKúszHTMLParser.handle_picCsdSr)rryrrr rIýszHTMLParser.unknown_declcCstjdtdd�t|ƒS)NzZThe unescape method is deprecated and will be removed in 3.5, use html.unescape() instead.r/)Ú stacklevel)ÚwarningsÚwarnÚDeprecationWarningr)rÚsrrr rs þzHTMLParser.unescape)r )Ú__name__Ú __module__Ú __qualname__Ú__doc__rhr rrr r!r"r(r*rrErYrDrArarBrfrgrvrOrRr=rGrJrKrIrrrrr r@s:     3"()r‚r$r{rZhtmlrÚ__all__r%rrSrQrMr?rFr\Z commentcloserbrcÚVERBOSErrrtrurrrrrr Ús.           ÿò