Warning: session_start(): Session cannot be started after headers have already been sent in /home/tvrreohg/public_html/manga.php on line 13
3 Aj,~ @sddlmZmZmZddlmZddlmZmZddl Z ddl Z ddl m Z m Z ddlZddlmZmZmZmZddlmZdd lmZed d eDZed d eDZed d eDZeeddgBZdZejredDdkrejddkste j eddEe!ddZ"n e j eZ"dddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2h Z#e j d3Z$iZ%Gd4d5d5e&Z'd6d7Z(Gd8d9d9e&Z)Gd:d;d;e)Z*Gdd?d?e&Z-Gd@dAdAe&Z.dBdCZ/dS)F)absolute_importdivisionunicode_literals) text_type) http_clienturllibN)BytesIOStringIO)EOFspaceCharacters asciiLettersasciiUppercase)_ReparseException)_utilscCsg|]}|jdqS)ascii)encode).0itemr9/tmp/pip-build-_d5lkt3n/html5lib/html5lib/_inputstream.py srcCsg|]}|jdqS)r)r)rrrrrrscCsg|]}|jdqS)r)r)rrrrrrs>.)sumr)r rrrr&XszBufferedStream._bufferedBytescCs<|jj|}|jj||jdd7<t||jd<|S)Nrr )rr.rappendrr")r r-datarrrr+[s   zBufferedStream._readStreamcCs|}g}|jd}|jd}x|t|jkr|dkr|dks@t|j|}|t||krn|}|||g|_n"t||}|t|g|_|d7}|j||||||8}d}qW|r|j|j|dj|S)Nrr )rr"rr'r0r+join)r r-remainingBytesrv bufferIndex bufferOffset bufferedData bytesToReadrrrr,bs&     zBufferedStream._readFromBufferN) __name__ __module__ __qualname____doc__r!r%r*r.r&r+r,rrrrr3s  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) _encoding)endswith)rxrrrrsz#HTMLInputStream..z3Cannot set an encoding with a unicode input, set %r) isinstancer HTTPResponserresponseaddbasefphasattrr.r TypeErrorHTMLUnicodeInputStreamHTMLBinaryInputStream)sourcekwargs isUnicode encodingsrrrHTMLInputStream}s     rNc@speZdZdZdZddZddZddZd d Zd d Z d dZ dddZ ddZ ddZ dddZddZdS)rHzProvides 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"characterErrorsUCS4characterErrorsUCS2newLineslookupEncoding charEncoding openStream dataStreamreset)r rJrrrr!s   zHTMLUnicodeInputStream.__init__cCs.d|_d|_d|_g|_d|_d|_d|_dS)Nr)r$ chunkSize chunkOffseterrors prevNumLines prevNumCols_bufferedCharacter)r rrrrYszHTMLUnicodeInputStream.resetcCst|dr|}nt|}|S)zvProduces a file object from source. source can be either a file object, local filename or a string. r.)rFr )r rJrrrrrWs z!HTMLUnicodeInputStream.openStreamcCsT|j}|jdd|}|j|}|jdd|}|dkr@|j|}n ||d}||fS)N rr r)r$countr^rfindr_)r r(r$nLines positionLine lastLinePospositionColumnrrr _positions   z HTMLUnicodeInputStream._positioncCs|j|j\}}|d|fS)z:Returns (line, col) of the current position in the stream.r )rhr\)r linecolrrrrszHTMLUnicodeInputStream.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 )r\r[ readChunkr r$)r r\charrrrrls   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)NrZrFr iiz ra Trrr)_defaultChunkSizerhr[r^r_r$r\rXr.r`r"ordrQreplace)r r[r1lastvrrrrks0           z HTMLUnicodeInputStream.readChunkcCs,x&tttj|D]}|jjdqWdS)Nzinvalid-codepoint)ranger"invalid_unicode_refindallr]r0)r r1_rrrrRsz*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 ) rtfinditerrpgroupstartrisSurrogatePairsurrogatePairToCodepointnon_bmp_invalid_codepointsr]r0r")r r1skipmatch codepointr#char_valrrrrS#s   z*HTMLUnicodeInputStream.characterErrorsUCS2Fc Csyt||f}Wnltk r|x|D]}t|dks&tq&Wdjdd|D}|s^d|}tjd|}t||f<YnXg}x||j|j|j }|dkr|j |j krPn0|j }||j kr|j |j|j |||_ P|j |j|j d|j sPqWdj|} | 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. rZcSsg|]}dt|qS)z\x%02x)rp)rcrrrrHsz5HTMLUnicodeInputStream.charsUntil..z^%sz[%s]+N)charsUntilRegExKeyErrorrpr'r3recompilerr$r\r[endr0rk) r charactersoppositecharsrregexr5mrrrrr charsUntil:s2     z!HTMLUnicodeInputStream.charsUntilcCsT|tk rP|jdkr.||j|_|jd7_n"|jd8_|j|j|ksPtdS)Nrr )r r\r$r[r')r rlrrrungetis   zHTMLUnicodeInputStream.unget)N)F)r:r;r<r=ror!rYrWrhrrlrkrRrSrrrrrrrHs   & /rHc@sLeZdZdZdddZddZd d Zdd d Zd dZddZ ddZ dS)rIzProvides 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-1252TcCsn|j||_tj||jd|_d|_||_||_||_||_ ||_ |j ||_ |j ddk sbt |jdS)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) idrN)rW rawStreamrHr! numBytesMetanumBytesChardetoverride_encodingtransport_encodingsame_origin_parent_encodinglikely_encodingdefault_encodingdetermineEncodingrVr'rY)r rJrrrrr useChardetrrrr!s  zHTMLBinaryInputStream.__init__cCs&|jdjj|jd|_tj|dS)Nrrq)rV codec_info streamreaderrrXrHrY)r rrrrYszHTMLBinaryInputStream.resetc CsLt|dr|}nt|}y|j|jWntk rFt|}YnX|S)zvProduces a file object from source. source can be either a file object, local filename or a string. r.)rFrr*r% Exceptionr)r rJrrrrrWs 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|rtyddl m }Wnt k rYnXg}|}xF|j s>|j j|j}t|ts t|s(P|j||j|qW|jt|jd}|j jd|dk rt|dfSt|jdf}|ddk r|StddfS)NrOr tentativezutf-16)UniversalDetectorencodingz windows-1252) detectBOMrUrrdetectEncodingMetarname startswithrchardet.universaldetectorr ImportErrordonerr.rrAr-r'r0feedcloseresultr*r)r chardetrVrbuffersdetectorrrrrrrsR           z'HTMLBinaryInputStream.determineEncodingcCs|jddkstt|}|dkr&dS|jdkrFtd}|dk stnT||jdkrf|jddf|_n4|jjd|df|_|jtd|jd|fdS) Nr rOutf-16beutf-16lezutf-8rzEncoding changed from %s to %s)rr)rVr'rUrrr*rYr)r newEncodingrrrchangeEncodings   z$HTMLBinaryInputStream.changeEncodingc Cstjdtjdtjdtjdtjdi}|jjd}t|t s"rIc@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 raisedcCst|tsttj||jS)N)rAr-r'__new__lower)r valuerrrrFszEncodingBytes.__new__cCs d|_dS)Nr r)rh)r rrrrr!JszEncodingBytes.__init__cCs|S)Nr)r rrr__iter__NszEncodingBytes.__iter__cCs>|jd}|_|t|kr"tn |dkr.t|||dS)Nr r)rhr" StopIterationrG)r prrr__next__Qs  zEncodingBytes.__next__cCs|jS)N)r)r rrrnextYszEncodingBytes.nextcCsB|j}|t|krtn |dkr$t|d|_}|||dS)Nrr )rhr"rrG)r rrrrprevious]s zEncodingBytes.previouscCs|jt|krt||_dS)N)rhr"r)r rrrr setPositionfszEncodingBytes.setPositioncCs*|jt|krt|jdkr"|jSdSdS)Nr)rhr"r)r rrr getPositionks  zEncodingBytes.getPositioncCs||j|jdS)Nr )r)r rrrgetCurrentByteuszEncodingBytes.getCurrentBytecCsL|j}x:|t|kr@|||d}||kr6||_|S|d7}qW||_dS)zSkip past a list of charactersr N)rr"rh)r rrrrrrr~zs zEncodingBytes.skipcCsL|j}x:|t|kr@|||d}||kr6||_|S|d7}qW||_dS)Nr )rr"rh)r rrrrrr skipUntils zEncodingBytes.skipUntilcCs(|j||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)rrr")r r-r5rrr matchBytesszEncodingBytes.matchBytesc Cs>y |j||jt|d|_Wntk r8tYnXdS)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 matchr T)indexrr"rh ValueErrorr)r r-rrrjumpTos   zEncodingBytes.jumpToN)r:r;r<r=rr!rrrrrrpropertyrr currentBytespaceCharactersBytesr~rrrrrrrrBs      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__cCsd|jkrdSd|jfd|jfd|jfd|jfd|jfd|jff}x|jD]|}d}y|jjdWntk rxPYnXxD|D]<\}}|jj|ry |}PWqtk rd}PYqXqW|sJPqJW|j S) Ns)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 getAttributerrUContentAttrParserrparse)r hasPragmapendingEncodingattrtentativeEncodingcodec 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 endTagr1rrrrrrs     z EncodingParser.handlePossibleTagcCs |jjdS)Nr)r1r)r rrrrszEncodingParser.handleOthercCs|j}|jttdgB}|dks2t|dks2t|d kr>dSg}g}xt|dkrX|rXPnX|tkrl|j}PnD|d krdj|dfS|tkr|j|j n|dkrdS|j|t |}qHW|dkr|j dj|dfSt ||j}|d krT|}xt |}||kr(t |dj|dj|fS|tkrB|j|j n |j|qWnJ|dkrldj|dfS|tkr|j|j n|dkrdS|j|x^t |}|t krdj|dj|fS|tkr|j|j n|dkrdS|j|qWdS) z_Return a name,value pair for the next attribute in the stream, if one is found, or None/Nr r=r2'")rN)rr)rr) r1r~r frozensetr"r'r3asciiUppercaseBytesr0rrrr)r r1rattrName attrValue quoteCharrrrrsh             zEncodingParser.getAttributeN) r:r;r<r=r!rrrrrrrrrrrrrs$rc@seZdZddZddZdS)rcCst|tst||_dS)N)rAr-r'r1)r r1rrrr!aszContentAttrParser.__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)r1rrr~rrrr)r quoteMark oldPositionrrrres.       zContentAttrParser.parseN)r:r;r<r!rrrrrr`srcCs`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)rAr-decodeUnicodeDecodeError webencodingslookupAttributeError)rrrrrUs  rUrr)0 __future__rrrsixrZ six.movesrrrriorr r constantsr r r rrrZrrrrrrinvalid_unicode_no_surrogaterPrbr'revalrtr}ascii_punctuation_rerobjectrrNrHrIr-rrrrUrrrrsP            JgIb='