t_c @`sddlmZmZmZddlmZddlmZmZddl Z ddl Z ddl m Z m Z ddlmZddlmZmZmZmZdd lmZdd lmZegeD]Zejd ^qZegeD]Zejd ^qZegeD]Zejd ^qZeed d gBZdZej re j!ed e"ddZ#ne j!eZ#ddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1h Z$e j!d2Z%iZ&d3e'fd4YZ(d5Z)d6e'fd7YZ*d8e*fd9YZ+d:e,fd;YZ-d<e'fd=YZ.d>e'fd?YZ/d@Z0dS(Ai(tabsolute_importtdivisiontunicode_literals(t text_type(t http_clientturllibN(tBytesIOtStringIO(t webencodingsi(tEOFtspaceCharacterst asciiLetterstasciiUppercase(t_ReparseException(t_utilsuasciit>tt|j||krL|t|j|8}|d7}qW||g|_dS(Nii(RRR(RRtoffsetti((sR/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/_inputstream.pytseekFs cC`sp|js|j|S|jdt|jkr_|jdt|jdkr_|j|S|j|SdS(Niii(Rt _readStreamRRt_readFromBuffer(Rtbytes((sR/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/_inputstream.pytreadOs     cC`s&tg|jD]}t|^q S(N(tsumRR(Rtitem((sR/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/_inputstream.pyt_bufferedBytesXscC`sL|jj|}|jj||jdcd7 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) u􏿿iiuutf-8ucertainN( Rtsupports_lone_surrogatestNonetreportCharacterErrorsRtcharacterErrorsUCS4tcharacterErrorsUCS2tnewLinestlookupEncodingt charEncodingt openStreamt dataStreamtreset(RR=((sR/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/_inputstream.pyRs    cC`sCd|_d|_d|_g|_d|_d|_d|_dS(Nui(Rt chunkSizet chunkOffsetterrorst prevNumLinest prevNumColsRDt_bufferedCharacter(R((sR/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/_inputstream.pyRMs      cC`s(t|dr|}n t|}|S(uvProduces a file object from source. source can be either a file object, local filename or a string. uread(R8R(RR=R((sR/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/_inputstream.pyRKs  cC`st|j}|jdd|}|j|}|jdd|}|dkr\|j|}n||d}||fS(Nu iii(RtcountRQtrfindRR(RRRtnLinest positionLinet lastLinePostpositionColumn((sR/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/_inputstream.pyt _positions   cC`s&|j|j\}}|d|fS(u:Returns (line, col) of the current position in the stream.i(RZRO(Rtlinetcol((sR/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/_inputstream.pyRscC`sL|j|jkr%|js%tSn|j}|j|}|d|_|S(uo Read one character from the stream or queue if available. Return EOF when EOF is reached. i(RORNt readChunkR R(RROtchar((sR/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/_inputstream.pyR^s    cC`sO|dkr|j}n|j|j\|_|_d|_d|_d|_|jj |}|j r|j |}d|_ n |st St |dkrt |d}|dksd|kodknr|d|_ |d }qn|jr|j|n|jdd }|jd d }||_t ||_tS( Nuiiii iiu u u (RDt_defaultChunkSizeRZRNRQRRRRORLR!RSR7RtordREtreplacetTrue(RRNR&tlastv((sR/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/_inputstream.pyR]s0        (   cC`s:x3tttj|D]}|jjdqWdS(Nuinvalid-codepoint(trangeRtinvalid_unicode_retfindallRPR%(RR&t_((sR/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/_inputstream.pyRFs"cC`st}xtj|D]}|r(qnt|j}|j}tj|||d!rtj|||d!}|t kr|j j dnt }q|dkr|dkr|t |dkr|j j dqt}|j j dqWdS(Niuinvalid-codepointiii(R7RetfinditerR`tgrouptstartRtisSurrogatePairtsurrogatePairToCodepointtnon_bmp_invalid_codepointsRPR%RbR(RR&tskiptmatcht codepointRtchar_val((sR/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/_inputstream.pyRG#s    c C`sTyt||f}Wnqtk rdjg|D]}dt|^q1}|scd|}ntjd|}t||f 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) iidN(RKt rawStreamR;Rt numBytesMetatnumBytesChardettoverride_encodingttransport_encodingtsame_origin_parent_encodingtlikely_encodingtdefault_encodingtdetermineEncodingRJRM(RR=RRRRRt useChardet((sR/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/_inputstream.pyRs       cC`s3|jdjj|jd|_tj|dS(Niureplace(RJt codec_infot streamreaderRRLR;RM(R((sR/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/_inputstream.pyRMs"cC`s_t|dr|}n t|}y|j|jWntk rZt|}nX|S(uvProduces a file object from source. source can be either a file object, local filename or a string. uread(R8RRRt ExceptionR(RR=R((sR/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/_inputstream.pyRKs   cC`s |jdf}|ddk r&|St|jdf}|ddk rO|St|jdf}|ddk rx|S|jdf}|ddk r|St|jdf}|ddk r|djjd r|St|j df}|ddk r|S|ryddl m }Wnt k r4qXg}|}xF|j s|jj|j}|soPn|j||j|qGW|jt|jd}|jjd|dk r|dfSnt|jdf}|ddk r|StddfS(Nucertainiu tentativeuutf-16(tUniversalDetectoruencodingu windows-1252(t detectBOMRDRIRRtdetectEncodingMetaRtnamet startswithRt%pip._vendor.chardet.universaldetectorRt ImportErrortdoneRR!RR%tfeedtclosetresultRR(RtchardetRJRtbufferstdetectorRtencoding((sR/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/_inputstream.pyRsP'       cC`st|}|dkrdS|jdkr:td}nr||jdkrf|jddf|_nF|jjd|df|_|jtd|jd|fdS(Nuutf-16beuutf-16leuutf-8iucertainuEncoding changed from %s to %s(uutf-16beuutf-16le(RIRDRRJRRRMR (Rt newEncoding((sR/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/_inputstream.pytchangeEncodings    cC`sidtj6dtj6dtj6dtj6dtj6}|jjd}|j|d }d}|s|j|}d}|s|j|d }d}qn|r|jj |t |S|jj d d Sd S( uAttempts 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 Noneuutf-8uutf-16leuutf-16beuutf-32leuutf-32beiiiiN( tcodecstBOM_UTF8t BOM_UTF16_LEt BOM_UTF16_BEt BOM_UTF32_LEt BOM_UTF32_BERR!tgetRRIRD(RtbomDicttstringRR((sR/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/_inputstream.pyRs$   cC`sk|jj|j}t|}|jjd|j}|dk rg|jdkrgtd}n|S(u9Report the encoding declared by the meta element iuutf-16beuutf-16leuutf-8N(uutf-16beuutf-16le( RR!RtEncodingParserRt getEncodingRDRRI(RRtparserR((sR/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/_inputstream.pyR3s  N( R/R0R1RDRbRRMRKRRRR(((sR/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/_inputstream.pyR<zs(   >  "t EncodingBytescB`seZdZdZdZdZdZdZdZdZ dZ e e e Z d Z e e Zed Zd Zd Zd ZRS(uString-like object with an associated position and various extra methods If the position is ever greater than the string length then an exception is raisedcC`stj||jS(N(R t__new__tlower(Rtvalue((sR/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/_inputstream.pyRFscC`s d|_dS(Ni(RZ(RR((sR/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/_inputstream.pyRJscC`s|S(N((R((sR/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/_inputstream.pyt__iter__NscC`sS|jd}|_|t|kr/tn|dkrDtn|||d!S(Nii(RZRt StopIterationR:(Rtp((sR/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/_inputstream.pyt__next__Qs    cC`s |jS(N(R(R((sR/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/_inputstream.pytnextYscC`sY|j}|t|kr$tn|dkr9tn|d|_}|||d!S(Nii(RZRRR:(RR((sR/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/_inputstream.pytprevious]s    cC`s+|jt|krtn||_dS(N(RZRR(RR((sR/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/_inputstream.pyt setPositionfs cC`s<|jt|krtn|jdkr4|jSdSdS(Ni(RZRRRD(R((sR/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/_inputstream.pyt getPositionks  cC`s||j|jd!S(Ni(R(R((sR/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/_inputstream.pytgetCurrentByteuscC`sc|j}xJ|t|krU|||d!}||krH||_|S|d7}q W||_dS(uSkip past a list of charactersiN(RRRZRD(RRyRRz((sR/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/_inputstream.pyRnzs    cC`sc|j}xJ|t|krU|||d!}||krH||_|S|d7}q W||_dS(Ni(RRRZRD(RRyRRz((sR/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/_inputstream.pyt skipUntils    cC`s7|j||j}|r3|jt|7_n|S(uLook 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(RR R*((sR/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/_inputstream.pyt matchBytesscC`sHy*|j||jt|d|_Wntk rCtnXtS(uLook for the next sequence of bytes matching a given sequence. If a match is found advance the position to the last byte of the matchi(tindexRRRZt ValueErrorRRb(RR ((sR/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/_inputstream.pytjumpTos *  (R/R0R1RRRRRRRRtpropertyRRt currentBytetspaceCharactersBytesRnRRR(((sR/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/_inputstream.pyRBs           RcB`s_eZdZdZdZdZdZdZdZdZ dZ d Z RS( u?Mini parser for detecting character encoding from meta elementscC`st||_d|_dS(u3string - the data to work on for encoding detectionN(RR&RDR(RR&((sR/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/_inputstream.pyRscC`s d|jkrdSd|jfd|jfd|jfd|jfd|jfd|jff}x|jD]}t}y|jjdWnt k rPnXxR|D]J\}}|jj |ry|}PWqt k rt }PqXqqW|skPqkqkW|j S(Ns(R&R(R((sR/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/_inputstream.pyRscC`sK|jjtkrtSt}d}x"trF|j}|dkrGtS|ddkr|ddk}|rC|dk rC||_tSq%|ddkr|d}t|}|dk rC||_tSq%|ddkr%t t |d}|j }|dk rCt|}|dk r@|r4||_tS|}q@qCq%q%WdS(Nis http-equivis content-typetcharsettcontent( R&RRRbR7RDt getAttributeRRItContentAttrParserRtparse(Rt hasPragmatpendingEncodingtattrttentativeEncodingtcodect contentParser((sR/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/_inputstream.pyRs:             cC`s |jtS(N(thandlePossibleTagR7(R((sR/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/_inputstream.pyRscC`st|j|jtS(N(RR&RRb(R((sR/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/_inputstream.pyRs cC`s|j}|jtkr9|r5|j|jntS|jt}|dkra|jn+|j}x|dk r|j}qpWtS(NR( R&RtasciiLettersBytesRRRbRtspacesAngleBracketsRRD(RtendTagR&RzR((sR/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/_inputstream.pyRs      cC`s|jjdS(NR(R&R(R((sR/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/_inputstream.pyRscC`s|j}|jttdgB}|dkr5dSg}g}xtr|dkr`|r`Pnz|tkr||j}Pn^|d krdj|dfS|tkr|j|j n|dkrdS|j|t |}qDW|dkr|j dj|dfSt ||j}|d kr|}xtrt |}||krt |dj|dj|fS|tkr|j|j q>|j|q>Wn^|dkrdj|dfS|tkr|j|j n|dkr dS|j|x}trt |}|t krSdj|dj|fS|tkru|j|j q|dkrdS|j|qWdS( u_Return a name,value pair for the next attribute in the stream, if one is found, or Nonet/Rt=R't't"N(RN(RR(RR( R&RnRt frozensetRDRbR(tasciiUppercaseBytesR%RRRR(RR&RztattrNamet attrValuet quoteChar((sR/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/_inputstream.pyRsf                            ( R/R0R1RRRRRRRRR(((sR/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/_inputstream.pyRs    $    RcB`seZdZdZRS(cC`s ||_dS(N(R&(RR&((sR/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/_inputstream.pyRascC`s:y!|jjd|jjd7_|jj|jjdksHdS|jjd7_|jj|jjdkr|jj}|jjd7_|jj}|jj|r|j||jj!SdSnP|jj}y(|jjt|j||jj!SWntk r|j|SXWntk r5dSXdS(NRiRRR(RR( R&RRRnRRDRRR(Rt quoteMarkt oldPosition((sR/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/_inputstream.pyRes.       (R/R0RR(((sR/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/_inputstream.pyR`s cC`swt|tr:y|jd}Wq:tk r6dSXn|dk roytj|SWqstk rkdSXndSdS(u{Return the python codec name corresponding to an encoding or None if the string doesn't correspond to a valid encoding.uasciiN(R2R tdecodetUnicodeDecodeErrorRDRtlookuptAttributeError(R((sR/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/_inputstream.pyRIs   (1t __future__RRRtpip._vendor.sixRtpip._vendor.six.movesRRRRttioRRt pip._vendorRt constantsR R R R R R'RRR#tencodeRRRRtinvalid_unicode_no_surrogateRCRutevalReRmtascii_punctuation_reRrtobjectRRBR;R<R RRRRI(((sR/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/html5lib/_inputstream.pytsH  "(((   J b'