PNG  IHDR;IDATxܻn0K )(pA 7LeG{ §㻢|ذaÆ 6lذaÆ 6lذaÆ 6lom$^yذag5bÆ 6lذaÆ 6lذa{ 6lذaÆ `}HFkm,mӪôô! x|'ܢ˟;E:9&ᶒ}{v]n&6 h_tڠ͵-ҫZ;Z$.Pkž)!o>}leQfJTu іچ\X=8Rن4`Vwl>nG^is"ms$ui?wbs[m6K4O.4%/bC%t Mז -lG6mrz2s%9s@-k9=)kB5\+͂Zsٲ Rn~GRC wIcIn7jJhۛNCS|j08yiHKֶۛkɈ+;SzL/F*\Ԕ#"5m2[S=gnaPeғL lذaÆ 6l^ḵaÆ 6lذaÆ 6lذa; _ذaÆ 6lذaÆ 6lذaÆ RIENDB` 3 B;W~)@sddlmZmZmZddlmZmZddlmZm Z ddl Z ddl Z ddl Z ddl mZmZmZmZddl mZddlmZdd lmZydd lmZWnek reZYnXed d eDZed d eDZedd eDZeeddgBZdZejr$e j eddEe!ddZ"n e j eZ"e#ddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3g Z$e j d4Z%iZ&Gd5d6d6e'Z(d7d8Z)Gd9d:d:e'Z*Gd;d<dd>e,Z-Gd?d@d@e'Z.GdAdBdBe'Z/dCdDZ0dS)F)absolute_importdivisionunicode_literals) text_type binary_type) http_clienturllibN)EOFspaceCharacters asciiLettersasciiUppercase)ReparseException)_utils)StringIO)BytesIOcCsg|]}|jdqS)ascii)encode).0itemr"/usr/lib/python3.6/_inputstream.py srcCsg|]}|jdqS)r)r)rrrrrrscCsg|]}|jdqS)r)r)rrrrrrs>.)sumr)r!rrr_bufferedBytes^szBufferedStream._bufferedBytescCs<|jj|}|jj||jdd7<t||jd<|S)Nrr )rr-rappendr r#)r!r,datarrrr*as   zBufferedStream._readStreamcCs|}g}|jd}|jd}x|t|jkr|dkr|j|}|t||krb|}|||g|_n"t||}|t|g|_|d7}|j||||||8}d}qW|r|j|j|dj|S)Nrr )r r#rr0r*join)r!r,ZremainingBytesrvZ bufferIndexZ bufferOffsetZ bufferedDataZ bytesToReadrrrr+hs$    zBufferedStream._readFromBufferN) __name__ __module__ __qualname____doc__r"r&r)r-r/r*r+rrrrr9s  rcKst|tjs(t|tjjr.t|jtjr.d}n&t|drJt|jdt }n t|t }|rdd|D}|rvt d|t |f|St |f|SdS)NFr-rcSsg|]}|jdr|qS)Z _encoding)endswith)rxrrrrsz#HTMLInputStream..z3Cannot set an encoding with a unicode input, set %r) isinstancerZ HTTPResponserZresponseZaddbasefphasattrr-r TypeErrorHTMLUnicodeInputStreamHTMLBinaryInputStream)sourcekwargsZ isUnicodeZ encodingsrrrHTMLInputStreams     rCc@speZdZdZdZddZddZddZd d Zd d Z d dZ dddZ ddZ ddZ dddZddZdS)r?zProvides a unicode stream of characters to the HTMLTokenizer. This class takes care of character encoding and removing or replacing incorrect byte-sequences and also provides column and line tracking. i(cCsZtjsd|_ntddkr$|j|_n|j|_dg|_tddf|_|j ||_ |j dS)aInitialises the HTMLInputStream. HTMLInputStream(source, [encoding]) -> Normalized stream from source for use by html5lib. source can be either a file-object, local filename or a string. The optional encoding parameter must be a string that indicates the encoding. If specified, that encoding will be used, regardless of any BOM or later declaration (such as in a meta element) Nu􏿿r rzutf-8certain) rsupports_lone_surrogatesreportCharacterErrorsr#characterErrorsUCS4characterErrorsUCS2ZnewLineslookupEncoding charEncoding openStream dataStreamreset)r!rArrrr"s   zHTMLUnicodeInputStream.__init__cCs.d|_d|_d|_g|_d|_d|_d|_dS)Nr)r% chunkSize chunkOffseterrors prevNumLines prevNumCols_bufferedCharacter)r!rrrrMszHTMLUnicodeInputStream.resetcCst|dr|}nt|}|S)zvProduces a file object from source. source can be either a file object, local filename or a string. r-)r=r)r!rArrrrrKs z!HTMLUnicodeInputStream.openStreamcCsT|j}|jdd|}|j|}|jdd|}|dkr@|j|}n ||d}||fS)N rr r)r%countrRrfindrS)r!r'r%ZnLinesZ positionLineZ lastLinePosZpositionColumnrrr _positions   z HTMLUnicodeInputStream._positioncCs|j|j\}}|d|fS)z:Returns (line, col) of the current position in the stream.r )rXrP)r!linecolrrrr szHTMLUnicodeInputStream.positioncCs6|j|jkr|jstS|j}|j|}|d|_|S)zo Read one character from the stream or queue if available. Return EOF when EOF is reached. r )rPrO readChunkr r%)r!rPcharrrrr\s   zHTMLUnicodeInputStream.charNcCs|dkr|j}|j|j\|_|_d|_d|_d|_|jj|}|j rX|j |}d|_ n|s`dSt |dkrt |d }|dksd|kodknr|d |_ |dd}|j r|j ||j dd }|j d d }||_t ||_d S)NrNrFr iiz rU Trrr)_defaultChunkSizerXrOrRrSr%rPrLr-rTr#ordrFreplace)r!rOr1Zlastvrrrr[s0           z HTMLUnicodeInputStream.readChunkcCs,x&tttj|D]}|jjdqWdS)Nzinvalid-codepoint)ranger#invalid_unicode_refindallrQr0)r!r1_rrrrG%sz*HTMLUnicodeInputStream.characterErrorsUCS4cCsd}xtj|D]}|rqt|j}|j}tj|||drttj|||d}|tkrn|j j dd}q|dkr|dkr|t |dkr|j j dqd}|j j dqWdS)NFzinvalid-codepointTiir ) rcfinditerr`groupstartrZisSurrogatePairZsurrogatePairToCodepointnon_bmp_invalid_codepointsrQr0r#)r!r1skipmatchZ codepointr$Zchar_valrrrrH)s   z*HTMLUnicodeInputStream.characterErrorsUCS2Fc Csyt||f}WnNtk r^djdd|D}|s@d|}tjd|}t||f<YnXg}x||j|j|j}|dkr|j|jkrPn0|j }||jkr|j |j|j|||_P|j |j|jd|j sfPqfWdj|}|S)z Returns a string of characters from the stream up to but not including any character in 'characters' or EOF. 'characters' must be a container that supports the 'in' method and iteration over its characters. rNcSsg|]}dt|qS)z\x%02x)r`)rcrrrrNsz5HTMLUnicodeInputStream.charsUntil..z^%sz[%s]+N) charsUntilRegExKeyErrorr3recompilerlr%rPrOendr0r[) r!Z charactersZoppositecharsZregexr4mrrrrrr charsUntil@s.    z!HTMLUnicodeInputStream.charsUntilcCs@|dk r<|jdkr.||j|_|jd7_n|jd8_dS)Nrr )rPr%rO)r!r\rrrungetos   zHTMLUnicodeInputStream.unget)N)F)r5r6r7r8r_r"rMrKrXr r\r[rGrHrvrwrrrrr?s   & /r?c@sLeZdZdZdddZddZd d Zdd d Zd dZddZ ddZ dS)r@zProvides a unicode stream of characters to the HTMLTokenizer. This class takes care of character encoding and removing or replacing incorrect byte-sequences and also provides column and line tracking. N windows-1252TcCs\|j||_tj||jd|_d|_||_||_||_||_ ||_ |j ||_ |j dS)aInitialises the HTMLInputStream. HTMLInputStream(source, [encoding]) -> Normalized stream from source for use by html5lib. source can be either a file-object, local filename or a string. The optional encoding parameter must be a string that indicates the encoding. If specified, that encoding will be used, regardless of any BOM or later declaration (such as in a meta element) idN)rK rawStreamr?r" numBytesMetanumBytesChardetoverride_encodingtransport_encodingsame_origin_parent_encodinglikely_encodingdefault_encodingdetermineEncodingrJrM)r!rAr}r~rrrZ useChardetrrrr"s  zHTMLBinaryInputStream.__init__cCs&|jdjj|jd|_tj|dS)Nrra)rJZ codec_info streamreaderrzrLr?rM)r!rrrrMszHTMLBinaryInputStream.resetc CsDt|dr|}nt|}y|j|jWnt|}YnX|S)zvProduces a file object from source. source can be either a file object, local filename or a string. r-)r=rr)r&r)r!rArrrrrKs z HTMLBinaryInputStream.openStreamc Cs|jdf}|ddk r|St|jdf}|ddk r:|St|jdf}|ddk rX|S|jdf}|ddk rt|St|jdf}|ddk r|djjd r|St|jdf}|ddk r|S|rdyddl m }Wnt k rYnxXg}|}x6|j s.|j j|j}|sP|j||j|qW|jt|jd}|j jd|dk rd|dfSt|jdf}|ddk r|StddfS)NrDrZ tentativezutf-16)UniversalDetectorencodingz windows-1252) detectBOMrIr}r~detectEncodingMetarname startswithrZchardet.universaldetectorr ImportErrordonerzr-r|r0Zfeedcloseresultr)r)r!ZchardetrJrZbuffersZdetectorrrrrrrsP           z'HTMLBinaryInputStream.determineEncodingcCst|}|dkrdS|jdkr(td}nT||jdkrH|jddf|_n4|jjd|df|_|jtd|jd|fdS)Nutf-16beutf-16lezutf-8rrDzEncoding changed from %s to %s)rr)rIrrJrzr)rMr)r!Z newEncodingrrrchangeEncodings   z$HTMLBinaryInputStream.changeEncodingc Cstjdtjdtjdtjdtjdi}|jjd}|j|dd}d}|sp|j|}d}|sp|j|dd }d }|r|jj |t |S|jj d dSdS) zAttempts to detect at BOM at the start of the stream. If an encoding can be determined from the BOM return the name of the encoding otherwise return Nonezutf-8zutf-16lezutf-16bezutf-32lezutf-32beNrfr) codecsBOM_UTF8 BOM_UTF16_LE BOM_UTF16_BE BOM_UTF32_LE BOM_UTF32_BErzr-getr)rI)r!ZbomDictstringrr)rrrrs"     zHTMLBinaryInputStream.detectBOMcCsH|jj|j}t|}|jjd|j}|dk rD|jdkrDtd}|S)z9Report the encoding declared by the meta element rNutf-16beutf-16lezutf-8)rr)rzr-r{EncodingParserr) getEncodingrrI)r!rparserrrrrr9s z(HTMLBinaryInputStream.detectEncodingMeta)NNNNrxT)T) r5r6r7r8r"rMrKrrrrrrrrr@s ( >"r@c@seZdZdZddZddZddZdd Zd d Zd d Z ddZ ddZ e e e Z ddZe eZefddZddZddZddZdS) EncodingByteszString-like object with an associated position and various extra methods If the position is ever greater than the string length then an exception is raisedcCstj||jS)N)r,__new__lower)r!valuerrrrLszEncodingBytes.__new__cCs d|_dS)Nr r)rX)r!rrrrr"PszEncodingBytes.__init__cCs|S)Nr)r!rrr__iter__TszEncodingBytes.__iter__cCs>|jd}|_|t|kr"tn |dkr.t|||dS)Nr r)rXr# StopIterationr>)r!prrr__next__Ws  zEncodingBytes.__next__cCs|jS)N)r)r!rrrnext_szEncodingBytes.nextcCsB|j}|t|krtn |dkr$t|d|_}|||dS)Nrr )rXr#rr>)r!rrrrpreviouscs zEncodingBytes.previouscCs|jt|krt||_dS)N)rXr#r)r!r rrr setPositionlszEncodingBytes.setPositioncCs*|jt|krt|jdkr"|jSdSdS)Nr)rXr#r)r!rrr getPositionqs  zEncodingBytes.getPositioncCs||j|jdS)Nr )r )r!rrrgetCurrentByte{szEncodingBytes.getCurrentBytecCsL|j}x:|t|kr@|||d}||kr6||_|S|d7}qW||_dS)zSkip past a list of charactersr N)r r#rX)r!rsrrmrrrrks zEncodingBytes.skipcCsL|j}x:|t|kr@|||d}||kr6||_|S|d7}qW||_dS)Nr )r r#rX)r!rsrrmrrr skipUntils zEncodingBytes.skipUntilcCs>|j}|||t|}|j|}|r:|jt|7_|S)zLook for a sequence of bytes at the start of a string. If the bytes are found return True and advance the position to the byte after the match. Otherwise return False and leave the position alone)r r#r)r!r,rr1r4rrr matchBytess  zEncodingBytes.matchBytescCsR||jdj|}|dkrJ|jdkr,d|_|j|t|d7_dStdS)zLook for the next sequence of bytes matching a given sequence. If a match is found advance the position to the last byte of the matchNr rTrr)r findrXr#r)r!r,Z newPositionrrrjumpTos zEncodingBytes.jumpToN)r5r6r7r8rr"rrrrrrpropertyr r currentBytespaceCharactersBytesrkrrrrrrrrHs      rc@sXeZdZdZddZddZddZdd Zd d Zd d Z ddZ ddZ ddZ dS)rz?Mini parser for detecting character encoding from meta elementscCst||_d|_dS)z3string - the data to work on for encoding detectionN)rr1r)r!r1rrrr"s zEncodingParser.__init__c Csd|jfd|jfd|jfd|jfd|jfd|jff}x^|jD]T}d}xD|D]<\}}|jj|rJy |}PWqJtk rd}PYqJXqJW|s)r1r)r!rrrrszEncodingParser.handleCommentcCs|jjtkrdSd}d}x|j}|dkr.dS|ddkr^|ddk}|r|dk r||_dSq|ddkr|d}t|}|dk r||_dSq|ddkrtt|d}|j}|dk rt|}|dk r|r||_dS|}qWdS) NTFrs http-equivr s content-typescharsetscontent) r1rr getAttributerrIContentAttrParserrparse)r!Z hasPragmaZpendingEncodingattrZtentativeEncodingcodecZ contentParserrrrrs:      zEncodingParser.handleMetacCs |jdS)NF)handlePossibleTag)r!rrrrsz%EncodingParser.handlePossibleStartTagcCst|j|jdS)NT)rr1r)r!rrrrs z#EncodingParser.handlePossibleEndTagcCsf|j}|jtkr(|r$|j|jdS|jt}|dkrD|jn|j}x|dk r`|j}qNWdS)NTr)r1rasciiLettersBytesrrrspacesAngleBracketsr)r!ZendTagr1rmrrrrrs     z EncodingParser.handlePossibleTagcCs |jjdS)Nr)r1r)r!rrrrszEncodingParser.handleOthercCs|j}|jttdgB}|dkr&dSg}g}xt|dkr@|r@PnX|tkrT|j}PnD|d krjdj|dfS|tkr|j|jn|dkrdS|j|t|}q0W|dkr|j dj|dfSt||j}|d kr:|}xt|}||krt|dj|dj|fS|tkr*|j|jq|j|qWnJ|dkrRdj|dfS|tkrl|j|jn|dkrzdS|j|x^t|}|t krdj|dj|fS|tkr|j|jn|dkrdS|j|qWdS) z_Return a name,value pair for the next attribute in the stream, if one is found, or None/rN=r2'")rN)rr)rr) r1rkr frozensetr3asciiUppercaseBytesr0rrrr)r!r1rmZattrNameZ attrValueZ quoteCharrrrrsf             zEncodingParser.getAttributeN) r5r6r7r8r"rrrrrrrrrrrrrs$rc@seZdZddZddZdS)rcCs ||_dS)N)r1)r!r1rrrr"fszContentAttrParser.__init__cCsy|jjd|jjd7_|jj|jjdks8dS|jjd7_|jj|jjdkr|jj}|jjd7_|jj}|jj|r|j||jjSdSnF|jj}y|jjt|j||jjStk r|j|dSXWntk rdSXdS)Nscharsetr rrr)rr)r1rr rkrrrr)r!Z quoteMarkZ oldPositionrrrrjs.       zContentAttrParser.parseN)r5r6r7r"rrrrrresrcCs`t|tr.y|jd}Wntk r,dSX|dk rXy tj|Stk rTdSXndSdS)z{Return the python codec name corresponding to an encoding or None if the string doesn't correspond to a valid encoding.rN)r;rdecodeUnicodeDecodeError webencodingslookupAttributeError)rrrrrIs  rIr)1Z __future__rrrZsixrrZ six.movesrrrrprZ constantsr r r r rrNriorrrrrrrrZinvalid_unicode_no_surrogaterErqevalrcsetrjZascii_punctuation_rernobjectrrCr?r@r,rrrrIrrrrsV              JgIh6'