fMc@sJdZddlZddlZddlZejdZejdZejdZejdZejdZ ejdZ ejd Z ejd Z ejd Z ejd Zejd ZejdejZejdejZejdZejdZGdddeZGdddejZdS(uA parser for HTML and XHTML.iNu[&<]u &[a-zA-Z#]u%&([a-zA-Z][-.a-zA-Z0-9]*)[^a-zA-Z0-9]u)&#(?:[0-9]+|[xX][0-9a-fA-F]+)[^0-9a-fA-F]u <[a-zA-Z]u>u--\s*>u(([a-zA-Z][-.a-zA-Z0-9:_]*)(?:\s|/(?!>))*u$([a-zA-Z][^ />]*)(?:\s|/(?!>))*uJ\s*([a-zA-Z_][-.:a-zA-Z_0-9]*)(\s*=\s*(\'[^\']*\'|"[^"]*"|[^\s"\'=<>`]*))?u]((?<=[\'"\s/])[^\s/>][^\s/=>]*)(\s*=+\s*(\'[^\']*\'|"[^"]*"|(?![\'"])[^>\s]*))?(?:\s|/(?!>))*u <[a-zA-Z][-.a-zA-Z0-9:_]* # tag name (?:\s+ # whitespace before attribute name (?:[a-zA-Z_][-.:a-zA-Z0-9_]* # attribute name (?:\s*=\s* # value indicator (?:'[^']*' # LITA-enclosed value |\"[^\"]*\" # LIT-enclosed value |[^'\">\s]+ # bare value ) )? ) )* \s* # trailing whitespace uF <[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 comma )?(?:\s|/(?!>))* )* )? \s* # trailing whitespace u#cBs5|EeZdZdZdddZddZdS(uHTMLParseErroru&Exception raised for all parse errors.cCs'||_|d|_|d|_dS(Nii(umsgulinenouoffset(uselfumsguposition((u0/opt/alt/python33/lib64/python3.3/html/parser.pyu__init__Ps  uHTMLParseError.__init__cCsW|j}|jdk r,|d|j}n|jdk rS|d|jd}n|S(Nu , at line %du , column %di(umsgulinenouNoneuoffset(uselfuresult((u0/opt/alt/python33/lib64/python3.3/html/parser.pyu__str__Vs  uHTMLParseError.__str__N(NN(u__name__u __module__u __qualname__u__doc__uNoneu__init__u__str__(u __locals__((u0/opt/alt/python33/lib64/python3.3/html/parser.pyuHTMLParseErrorMsuHTMLParseErrorcBsd|EeZdZdZd:Zd;ddZddZdd Zd d Z d d Z d9Z ddZ ddZddZddZddZdddZddZddZdd Zd!d"Zd#d$Zd%d&Zd'd(Zd)d*Zd+d,Zd-d.Zd/d0Zd1d2Zd3d4Zd5d6Z d7d8Z!d9S(<u HTMLParseruFind 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). Entity references are passed by calling self.handle_entityref() with the entity reference as the argument. Numeric character references are passed to self.handle_charref() with the string containing the reference as the argument. uscriptustylecCs6|rtjdtddn||_|jdS(uInitialize and reset this instance. If strict is set to False (the default) the parser will parse invalid markup, otherwise it will raise an error. Note that the strict mode is deprecated. uThe strict mode is deprecated.u stackleveliN(uwarningsuwarnuDeprecationWarningustrictureset(uselfustrict((u0/opt/alt/python33/lib64/python3.3/html/parser.pyu__init__us   uHTMLParser.__init__cCs8d|_d|_t|_d|_tjj|dS(u1Reset this instance. Loses all unprocessed data.uu???N( urawdataulasttaguinteresting_normalu interestinguNoneu cdata_elemu _markupbaseu ParserBaseureset(uself((u0/opt/alt/python33/lib64/python3.3/html/parser.pyuresets     uHTMLParser.resetcCs!|j||_|jddS(uFeed data to the parser. Call this as often as you want, with as little or as much text as you want (may include '\n'). iN(urawdataugoahead(uselfudata((u0/opt/alt/python33/lib64/python3.3/html/parser.pyufeedsuHTMLParser.feedcCs|jddS(uHandle any buffered data.iN(ugoahead(uself((u0/opt/alt/python33/lib64/python3.3/html/parser.pyuclosesuHTMLParser.closecCst||jdS(N(uHTMLParseErrorugetpos(uselfumessage((u0/opt/alt/python33/lib64/python3.3/html/parser.pyuerrorsuHTMLParser.errorcCs|jS(u)Return full source of start tag: '<...>'.(u_HTMLParser__starttag_text(uself((u0/opt/alt/python33/lib64/python3.3/html/parser.pyuget_starttag_textsuHTMLParser.get_starttag_textcCs2|j|_tjd|jtj|_dS(Nu (uloweru cdata_elemureucompileuIu interesting(uselfuelem((u0/opt/alt/python33/lib64/python3.3/html/parser.pyuset_cdata_modesuHTMLParser.set_cdata_modecCst|_d|_dS(N(uinteresting_normalu interestinguNoneu cdata_elem(uself((u0/opt/alt/python33/lib64/python3.3/html/parser.pyuclear_cdata_modes uHTMLParser.clear_cdata_modec Cs|j}d}t|}x||kr|jj||}|rT|j}n|jraPn|}||kr|j|||n|j||}||krPn|j}|d|rqt j ||r|j |}n|d|r |j |}n|d|r-|j |}n|d|rN|j|}ng|d|r|jrx|j|}q|j|}n+|d|kr|jd|d}nP|dkr\|sPn|jr|jdn|jd |d}|dkr8|jd|d}|dkrB|d}qBn |d7}|j|||n|j||}q|d |rMtj ||}|r|jd d} |j| |j}|d |ds|d}n|j||}qqd ||dkrI|j|||d |j||d }nPq|d |rtj ||}|r|jd} |j| |j}|d |ds|d}n|j||}qntj ||}|re|ra|j||dkra|jr'|jdqa|j}||krH|}n|j||d}nPq|d|kr|jd |j||d}qPqqW|r||kr|j r|j||||j||}n||d|_dS(Niuu&#iu;u&u#EOF in middle of entity or char refi(urawdataulenu interestingusearchustartu cdata_elemu handle_datau updateposu startswithu starttagopenumatchuparse_starttagu parse_endtagu parse_commentuparse_piustrictuparse_declarationuparse_html_declarationuerrorufinducharrefugroupuhandle_charrefuendu entityrefuhandle_entityrefu incomplete( uselfuendurawdatauiunumatchuju startswithukuname((u0/opt/alt/python33/lib64/python3.3/html/parser.pyugoaheads                    "     uHTMLParser.goaheadcCs|j}|||ddkr0|j|S|||ddkrW|j|S|||djdkr|jd|d}|d krd S|j||d ||dS|j|SdS( Niu