tzh
2024-08-22 c7d0944258c7d0943aa7b2211498fd612971ce27
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
K\¬Qc@sdZddlZddlZejdƒZejdƒZejdƒZejdƒZejdƒZejdƒZ    ejd    ƒZ
ejd
ƒZ ejd ƒZ ejd ƒZ ejd ejƒZejdƒZejdƒZdefd„ƒYZdejfd„ƒYZdS(sA parser for HTML and XHTML.iÿÿÿÿNs[&<]s
&[a-zA-Z#]s%&([a-zA-Z][-.a-zA-Z0-9]*)[^a-zA-Z0-9]s)&#(?:[0-9]+|[xX][0-9a-fA-F]+)[^0-9a-fA-F]s    <[a-zA-Z]t>s--\s*>s(([a-zA-Z][-.a-zA-Z0-9:_]*)(?:\s|/(?!>))*s[a-zA-Z][^    
 />]*s]((?<=[\'"\s/])[^\s/>][^\s/=>]*)(\s*=+\s*(\'[^\']*\'|"[^"]*"|(?![\'"])[^>\s]*))?(?:\s|/(?!>))*s
  <[a-zA-Z][-.a-zA-Z0-9:_]*          # 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|/(?!>))*
     )*
   )?
  \s*                                # trailing whitespace
s#</\s*([a-zA-Z][-.a-zA-Z0-9:_]*)\s*>tHTMLParseErrorcBs#eZdZdd„Zd„ZRS(s&Exception raised for all parse errors.cCs3|s t‚||_|d|_|d|_dS(Nii(tAssertionErrortmsgtlinenotoffset(tselfRtposition((sR/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/HTMLParser.pyt__init__9s      cCsW|j}|jdk    r,|d|j}n|jdk    rS|d|jd}n|S(Ns , at line %ds , column %di(RRtNoneR(Rtresult((sR/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/HTMLParser.pyt__str__?s     N(NN(t__name__t
__module__t__doc__R    RR (((sR/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/HTMLParser.pyR6s t
HTMLParsercBs eZdZdZd„Zd„Zd„Zd„Zd„ZdZ
d„Z d    „Z d
„Z d „Zd „Zd d„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„ZdZd„Z RS( sÇFind 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.
    tscripttstylecCs|jƒdS(s#Initialize and reset this instance.N(treset(R((sR/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/HTMLParser.pyR_scCs8d|_d|_t|_d|_tjj|ƒdS(s1Reset this instance.  Loses all unprocessed data.ts???N(    trawdatatlasttagtinteresting_normalt interestingR    t
cdata_elemt
markupbaset
ParserBaseR(R((sR/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/HTMLParser.pyRcs
                cCs!|j||_|jdƒdS(s‘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').
        iN(Rtgoahead(Rtdata((sR/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/HTMLParser.pytfeedkscCs|jdƒdS(sHandle any buffered data.iN(R(R((sR/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/HTMLParser.pytclosetscCst||jƒƒ‚dS(N(Rtgetpos(Rtmessage((sR/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/HTMLParser.pyterrorxscCs|jS(s)Return full source of start tag: '<...>'.(t_HTMLParser__starttag_text(R((sR/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/HTMLParser.pytget_starttag_text}scCs2|jƒ|_tjd|jtjƒ|_dS(Ns </\s*%s\s*>(tlowerRtretcompiletIR(Rtelem((sR/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/HTMLParser.pytset_cdata_modescCst|_d|_dS(N(RRR    R(R((sR/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/HTMLParser.pytclear_cdata_mode…s    c
Cst|j}d}t|ƒ}x||kr|jj||ƒ}|rT|jƒ}n|jraPn|}||krŠ|j|||!ƒn|j||ƒ}||kr¬Pn|j}|d|ƒr7t    j
||ƒrè|j |ƒ}n¯|d|ƒr    |j |ƒ}nŽ|d|ƒr*|j |ƒ}nm|d|ƒrK|j|ƒ}nL|d|ƒrl|j|ƒ}n+|d|kr–|jdƒ|d}nP|dkr"|s­Pn|jd|dƒ}|dkr|jd|dƒ}|dkr |d}q n
|d7}|j|||!ƒn|j||ƒ}q|d    |ƒrÿtj
||ƒ}|rÂ|jƒd
d !}    |j|    ƒ|jƒ}|d |dƒsª|d}n|j||ƒ}qqd ||krû|j|dd
!ƒ|j|d
ƒ}nPq|d |ƒrtj
||ƒ}|r†|jdƒ}    |j|    ƒ|jƒ}|d |dƒsn|d}n|j||ƒ}qntj
||ƒ}|rÎ|rÊ|jƒ||krÊ|jdƒnPq|d|kr|jd ƒ|j||dƒ}qPqdstdƒ‚qW|rc||krc|j rc|j|||!ƒ|j||ƒ}n|||_dS(Nit<s</s<!--s<?s<!iRs&#iiÿÿÿÿt;t&s#EOF in middle of entity or char refsinteresting.search() lied(RtlenRtsearchtstartRt handle_datat    updatepost
startswitht starttagopentmatchtparse_starttagt parse_endtagt parse_commenttparse_pitparse_html_declarationtfindtcharreftgroupthandle_charreftendt    entityrefthandle_entityreft
incompleteR!R(
RR?RtitnR5tjR3tktname((sR/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/HTMLParser.pyRŒs                     
       cCsì|j}|||d!dkr0|jdƒn|||d!dkrT|j|ƒS|||d!dkrx|j|ƒS|||d!jƒd    krÛ|jd
|dƒ}|d kr»d S|j||d|!ƒ|d S|j|ƒSdS( Nis<!s+unexpected call to parse_html_declaration()is<!--is<![i    s    <!doctypeRiÿÿÿÿi(RR!R8tparse_marked_sectionR$R;t handle_decltparse_bogus_comment(RRCRtgtpos((sR/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/HTMLParser.pyR:ês       icCs|j}|||d!dkr0|jdƒn|jd|dƒ}|dkrVdS|rw|j||d|!ƒn|dS(    Nis<!s</s"unexpected call to parse_comment()Riÿÿÿÿi(s<!s</(RR!R;thandle_comment(RRCtreportRtpos((sR/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/HTMLParser.pyRJÿs     cCs€|j}|||d!dks,tdƒ‚tj||dƒ}|sLdS|jƒ}|j||d|!ƒ|jƒ}|S(Nis<?sunexpected call to parse_pi()iÿÿÿÿ(RRtpicloseR/R0t    handle_piR?(RRCRR5RE((sR/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/HTMLParser.pyR9 s    #  cCs€d|_|j|ƒ}|dkr(|S|j}|||!|_g}tj||dƒ}|sotdƒ‚|jƒ}|jdƒj    ƒ|_
}xî||kr‡t j||ƒ}|sÂPn|jdddƒ\}    }
} |
sïd} nX| d dko| dkns7| d dko2| dknrG| dd!} n| r_|j | ƒ} n|j |    j    ƒ| fƒ|jƒ}qšW|||!jƒ} | d kr+|jƒ\} }d |jkr| |jjd ƒ} t|jƒ|jjd ƒ}n|t|jƒ}|j|||!ƒ|S| jd
ƒrM|j||ƒn/|j||ƒ||jkr||j|ƒn|S( Niis#unexpected call to parse_starttag()iis'iÿÿÿÿt"Rs/>s
(Rs/>(R    R"tcheck_for_whole_start_tagRttagfindR5RR?R=R$RtattrfindtunescapetappendtstripRtcountR.trfindR1tendswiththandle_startendtagthandle_starttagtCDATA_CONTENT_ELEMENTSR)(RRCtendposRtattrsR5RFttagtmtattrnametrestt    attrvalueR?RR((sR/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/HTMLParser.pyR6sR              $$  cCsý|j}tj||ƒ}|rí|jƒ}|||d!}|dkrR|dS|dkr²|jd|ƒrx|dS|jd|ƒrŽdS|j||dƒ|jdƒn|dkrÂdS|d    krÒdS||krâ|S|dSntd
ƒ‚dS( NiRt/s/>iiÿÿÿÿsmalformed empty start tagRs6abcdefghijklmnopqrstuvwxyz=/ABCDEFGHIJKLMNOPQRSTUVWXYZswe should not get here!(RtlocatestarttagendR5R?R3R2R!R(RRCRRaREtnext((sR/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/HTMLParser.pyRRKs,           cCsŠ|j}|||d!dks,tdƒ‚tj||dƒ}|sLdS|jƒ}tj||ƒ}|s!|jdk    r—|j    |||!ƒ|St
j||dƒ}|sâ|||d!dkrÒ|dS|j |ƒSn|j ƒj ƒ}|jd|jƒƒ}|j|ƒ|dS|j dƒj ƒ}|jdk    ro||jkro|j    |||!ƒ|Sn|j|ƒ|jƒ|S(    Nis</sunexpected call to parse_endtagiiÿÿÿÿis</>R(RRt    endendtagR/R?t
endtagfindR5RR    R1ttagfind_tolerantRJR=R$R;t handle_endtagR*(RRCRR5RKt    namematchttagnameR(((sR/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/HTMLParser.pyR7ks8    #   
cCs!|j||ƒ|j|ƒdS(N(R\Rk(RR`R_((sR/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/HTMLParser.pyR[“scCsdS(N((RR`R_((sR/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/HTMLParser.pyR\˜scCsdS(N((RR`((sR/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/HTMLParser.pyRkœscCsdS(N((RRG((sR/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/HTMLParser.pyR> scCsdS(N((RRG((sR/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/HTMLParser.pyRA¤scCsdS(N((RR((sR/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/HTMLParser.pyR1¨scCsdS(N((RR((sR/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/HTMLParser.pyRL¬scCsdS(N((Rtdecl((sR/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/HTMLParser.pyRI°scCsdS(N((RR((sR/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/HTMLParser.pyRP´scCsdS(N((RR((sR/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/HTMLParser.pyt unknown_decl·scs2d|kr|S‡fd†}tjd||ƒS(NR-cs|jƒd}yZ|ddkri|d}|dd krSt|ddƒ}n t|ƒ}t|ƒSWntk
r†d|dSXd    dl}tjdkréid
d 6}t_x0|jj    ƒD]\}}t|ƒ||<qÆWnyˆj|SWnt
k
rd |dSXdS(Nit#itxtXis&#R,iÿÿÿÿu'taposR-(RqRr( tgroupstinttunichrt
ValueErrorthtmlentitydefsRt
entitydefsR    tname2codepointt    iteritemstKeyError(tstcRxRyRFtv(R(sR/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/HTMLParser.pytreplaceEntities¿s&
     s#&(#?[xX]?(?:[0-9a-fA-F]+|\w{1,8}));(R%tsub(RR}R€((RsR/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/HTMLParser.pyRU¼s (RRN(!R R RR]RRRRR!R    R"R#R)R*RR:RJR9R6RRR7R[R\RkR>RAR1RLRIRPRoRyRU(((sR/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/HTMLParser.pyRHs<                                        ^            4         (                                        (RRR%R&RRBR@R<R4ROt commentcloseRSRjRTtVERBOSERfRhRit    ExceptionRRR(((sR/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/HTMLParser.pyt<module>s&