ó
^\kdc        !   @` sÃ  d  d l  m Z m Z m Z d  d l m Z d  d l Z d  d l Z d d l m	 Z	 m
 Z
 m Z m Z d d l m Z m Z d d l m Z d  d l m Z y d  d	 l m Z Wn e k
 rÉ e Z n Xy d  d
 l m Z Wn' e k
 rd e f d „  ƒ  YZ n Xe g  e
 D] Z e j d ƒ ^ qƒ Z e g  e D] Z e j d ƒ ^ q:ƒ Z e g  e D] Z e j d ƒ ^ qbƒ Z e e d d g ƒ BZ e j d ƒ Z e  d d d d d d d d d d d d d d d d  d! d" d# d$ d% d& d' d( d) d* d+ d, d- d. d/ d0 g  ƒ Z! e j d1 ƒ Z" i  Z# d2 d@ d3 „  ƒ  YZ$ d e& e& d4 „ Z' d5 dA d6 „  ƒ  YZ( d7 e( f d8 „  ƒ  YZ) d9 e* f d: „  ƒ  YZ+ d; e f d< „  ƒ  YZ, d= e f d> „  ƒ  YZ- d? „  Z. d S(B   i    (   t   absolute_importt   divisiont   unicode_literals(   t	   text_typeNi   (   t   EOFt   spaceCharacterst   asciiLetterst   asciiUppercase(   t	   encodingst   ReparseException(   t   utils(   t   StringIO(   t   BytesIO(   t   BufferedIOBaseR   c           B` s   e  Z RS(    (   t   __name__t
   __module__(    (    (    sG   /var/www/testScraper/venv/build/pip/pip/_vendor/html5lib/inputstream.pyR      s   u   asciit   >t   <u¡   [---ÂŸí €-í¿¿ï·�-ï·¯ï¿¾ï¿¿ðŸ¿¾ðŸ¿¿ð¯¿¾ð¯¿¿ð¿¿¾ð¿¿¿ñ�¿¾ñ�¿¿ñŸ¿¾ñŸ¿¿ñ¯¿¾ñ¯¿¿ñ¿¿¾ñ¿¿¿ò�¿¾ò�¿¿òŸ¿¾òŸ¿¿ò¯¿¾ò¯¿¿ò¿¿¾ò¿¿¿ó�¿¾ó�¿¿óŸ¿¾óŸ¿¿ó¯¿¾ó¯¿¿ó¿¿¾ó¿¿¿ô�¿¾ô�¿¿]iþÿ iÿÿ iþÿ iÿÿ iþÿ iÿÿ iþÿ iÿÿ iþÿ iÿÿ iþÿ iÿÿ iþÿ iÿÿ iþÿ iÿÿ iþÿ	 iÿÿ	 iþÿ
 iÿÿ
 iþÿ iÿÿ iþÿ iÿÿ iþÿ iÿÿ iþÿ iÿÿ iþÿ iÿÿ iþÿ iÿÿ u   [	- -/:-@[-`{-~]t   BufferedStreamc           B` sM   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 RS(   uÆ   Buffering for streams that do not have buffering of their own

    The buffer is implemented as a list of chunks on the assumption that
    joining many strings will be slow since it is O(n**2)
    c         C` s%   | |  _  g  |  _ d d g |  _ d  S(   Niÿÿÿÿi    (   t   streamt   buffert   position(   t   selfR   (    (    sG   /var/www/testScraper/venv/build/pip/pip/_vendor/html5lib/inputstream.pyt   __init__5   s    		c         C` sJ   d } x, |  j  |  j d  D] } | t | ƒ 7} q W| |  j d 7} | S(   Ni    i   (   R   R   t   len(   R   t   post   chunk(    (    sG   /var/www/testScraper/venv/build/pip/pip/_vendor/html5lib/inputstream.pyt   tell:   s
    c         C` sk   | |  j  ƒ  k  s t ‚ | } d } x1 t |  j | ƒ | k  rW | | 8} | d 7} q' W| | g |  _ d  S(   Ni    i   (   t   _bufferedBytest   AssertionErrorR   R   R   (   R   R   t   offsett   i(    (    sG   /var/www/testScraper/venv/build/pip/pip/_vendor/html5lib/inputstream.pyt   seekA   s    
c         C` sp   |  j  s |  j | ƒ S|  j d t |  j  ƒ k r_ |  j d t |  j  d ƒ k r_ |  j | ƒ S|  j | ƒ Sd  S(   Ni    i   iÿÿÿÿ(   R   t   _readStreamR   R   t   _readFromBuffer(   R   t   bytes(    (    sG   /var/www/testScraper/venv/build/pip/pip/_vendor/html5lib/inputstream.pyt   readJ   s    	 c         C` s&   t  g  |  j D] } t | ƒ ^ q ƒ S(   N(   t   sumR   R   (   R   t   item(    (    sG   /var/www/testScraper/venv/build/pip/pip/_vendor/html5lib/inputstream.pyR   S   s    c         C` sL   |  j  j | ƒ } |  j j | ƒ |  j d c d 7<t | ƒ |  j d <| S(   Ni    i   (   R   R$   R   t   appendR   R   (   R   R#   t   data(    (    sG   /var/www/testScraper/venv/build/pip/pip/_vendor/html5lib/inputstream.pyR!   V   s
    c         C` s"  | } g  } |  j  d } |  j  d } xÍ | t |  j ƒ k  rõ | d k rõ | d k s\ t ‚ |  j | } | t | ƒ | k r› | } | | | g |  _  n/ t | ƒ | } | t | ƒ g |  _  | d 7} | j | | | | !ƒ | | 8} d } q) W| r| j |  j | ƒ ƒ n  d j | ƒ S(   Ni    i   u    (   R   R   R   R   R'   R!   t   join(   R   R#   t   remainingBytest   rvt   bufferIndext   bufferOffsett   bufferedDatat   bytesToRead(    (    sG   /var/www/testScraper/venv/build/pip/pip/_vendor/html5lib/inputstream.pyR"   ]   s&    $


(
   R   R   t   __doc__R   R   R    R$   R   R!   R"   (    (    (    sG   /var/www/testScraper/venv/build/pip/pip/_vendor/html5lib/inputstream.pyR   .   s   								c         C` s{   t  |  d ƒ r* t |  j d ƒ t ƒ } n t |  t ƒ } | rd | d  k	 rZ t d ƒ ‚ n  t |  ƒ St |  | | | ƒ Sd  S(   Nu   readi    u7   Cannot explicitly set an encoding with a unicode string(   t   hasattrt
   isinstanceR$   R   t   Nonet	   TypeErrort   HTMLUnicodeInputStreamt   HTMLBinaryInputStream(   t   sourcet   encodingt	   parseMetat   chardett	   isUnicode(    (    sG   /var/www/testScraper/venv/build/pip/pip/_vendor/html5lib/inputstream.pyt   HTMLInputStreamx   s    
R5   c           B` s}   e  Z d  Z d Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d d „ Z d	 „  Z d
 „  Z e d „ Z d „  Z RS(   u×   Provides 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 (  c         C` s†   t  d ƒ d k r3 |  j |  _ t j d ƒ |  _ n |  j |  _ t j d ƒ |  _ d g |  _ d	 |  _ |  j	 | ƒ |  _
 |  j ƒ  d S(
   u  Initialises 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)

        parseMeta - Look for a <meta> element containing encoding information

        u   ô�¿¿i   u	   [í €-í¿¿]u0   ([í €-í¯¿](?![í°€-í¿¿])|(?<![í €-í¯¿])[í°€-í¿¿])i    u   utf-8u   certainN(   u   utf-8u   certain(   R   t   characterErrorsUCS4t   reportCharacterErrorst   ret   compilet   replaceCharactersRegexpt   characterErrorsUCS2t   newLinest   charEncodingt
   openStreamt
   dataStreamt   reset(   R   R7   (    (    sG   /var/www/testScraper/venv/build/pip/pip/_vendor/html5lib/inputstream.pyR   ‘   s    	c         C` sC   d |  _  d |  _ d |  _ g  |  _ d |  _ d |  _ d  |  _ d  S(   Nu    i    (   R   t	   chunkSizet   chunkOffsett   errorst   prevNumLinest   prevNumColsR3   t   _bufferedCharacter(   R   (    (    sG   /var/www/testScraper/venv/build/pip/pip/_vendor/html5lib/inputstream.pyRG   ²   s    						c         C` s(   t  | d ƒ r | } n t | ƒ } | S(   uv   Produces a file object from source.

        source can be either a file object, local filename or a string.

        u   read(   R1   R   (   R   R7   R   (    (    sG   /var/www/testScraper/venv/build/pip/pip/_vendor/html5lib/inputstream.pyRE   À   s    	c         C` st   |  j  } | j d d | ƒ } |  j | } | j d d | ƒ } | d k r\ |  j | } n | | d } | | f S(   Nu   
i    iÿÿÿÿi   (   R   t   countRK   t   rfindRL   (   R   R   R   t   nLinest   positionLinet   lastLinePost   positionColumn(    (    sG   /var/www/testScraper/venv/build/pip/pip/_vendor/html5lib/inputstream.pyt	   _positionÎ   s    	c         C` s&   |  j  |  j ƒ \ } } | d | f S(   u:   Returns (line, col) of the current position in the stream.i   (   RT   RI   (   R   t   linet   col(    (    sG   /var/www/testScraper/venv/build/pip/pip/_vendor/html5lib/inputstream.pyR   Ù   s    c         C` sL   |  j  |  j k r% |  j ƒ  s% t Sn  |  j  } |  j | } | d |  _  | S(   uo    Read one character from the stream or queue if available. Return
            EOF when EOF is reached.
        i   (   RI   RH   t	   readChunkR   R   (   R   RI   t   char(    (    sG   /var/www/testScraper/venv/build/pip/pip/_vendor/html5lib/inputstream.pyRX   Þ   s    	c         C` sX  | d  k r |  j } n  |  j |  j ƒ \ |  _ |  _ d |  _ d |  _ d |  _ |  j j	 | ƒ } |  j
 r… |  j
 | } d  |  _
 n
 | s� t St | ƒ d k rö t | d ƒ } | d k sÙ d | k oÔ d k n rö | d |  _
 | d  } qö n  |  j | ƒ |  j j d | ƒ } | j d	 d
 ƒ } | j d d
 ƒ } | |  _ t | ƒ |  _ t S(   Nu    i    i   iÿÿÿÿi   i Ø  iÿÛ  u   ï¿½u   
u   
u   (   R3   t   _defaultChunkSizeRT   RH   RK   RL   R   RI   RF   R$   RM   t   FalseR   t   ordR>   RA   t   subt   replacet   True(   R   RH   R(   t   lastv(    (    sG   /var/www/testScraper/venv/build/pip/pip/_vendor/html5lib/inputstream.pyRW   í   s0    				(	c         C` s:   x3 t  t t j | ƒ ƒ ƒ D] } |  j j d ƒ q Wd  S(   Nu   invalid-codepoint(   t   rangeR   t   invalid_unicode_ret   findallRJ   R'   (   R   R(   R   (    (    sG   /var/www/testScraper/venv/build/pip/pip/_vendor/html5lib/inputstream.pyR=     s    "c         C` s  t  } xô t j | ƒ D]ã } | r( q n  t | j ƒ  ƒ } | j ƒ  } t j | | | d !ƒ r¢ t j | | | d !ƒ } | t	 k r™ |  j
 j d ƒ n  t } q | d k rã | d k rã | t | ƒ d k rã |  j
 j d ƒ q t  } |  j
 j d ƒ q Wd  S(   Ni   u   invalid-codepointi Ø  iÿß  i   (   RZ   Ra   t   finditerR[   t   groupt   startR
   t   isSurrogatePairt   surrogatePairToCodepointt   non_bmp_invalid_codepointsRJ   R'   R^   R   (   R   R(   t   skipt   matcht	   codepointR   t   char_val(    (    sG   /var/www/testScraper/venv/build/pip/pip/_vendor/html5lib/inputstream.pyRB     s     	c   
      C` s}  y t  | | f } Wnš t k
 r° x& | D] } t | ƒ d k  s+ t ‚ q+ Wd j g  | D] } d t | ƒ ^ qZ ƒ } | sŒ d | } n  t j d | ƒ } t  | | f <n Xg  } x° t ri| j |  j	 |  j
 ƒ } | d k rý |  j
 |  j k r?Pq?nB | j ƒ  } | |  j k r?| j |  j	 |  j
 | !ƒ | |  _
 Pn  | j |  j	 |  j
 ƒ |  j ƒ  sº Pqº qº Wd j | ƒ }	 |	 S(   uð    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.
        i€   u    u   \x%02xu   ^%su   [%s]+N(   t   charsUntilRegExt   KeyErrorR[   R   R)   R?   R@   R^   Rj   R   RI   R3   RH   t   endR'   RW   (
   R   t
   characterst   oppositet   charst   ct   regexR+   t   mRo   t   r(    (    sG   /var/www/testScraper/venv/build/pip/pip/_vendor/html5lib/inputstream.pyt
   charsUntil0  s2    ,%		c         C` so   | d  k	 rk |  j d k r= | |  j |  _ |  j d 7_ qk |  j d 8_ |  j |  j | k sk t ‚ n  d  S(   Ni    i   (   R3   RI   R   RH   R   (   R   RX   (    (    sG   /var/www/testScraper/venv/build/pip/pip/_vendor/html5lib/inputstream.pyt   unget_  s    N(   R   R   R0   RY   R   RG   RE   RT   R   RX   R3   RW   R=   RB   RZ   Rw   Rx   (    (    (    sG   /var/www/testScraper/venv/build/pip/pip/_vendor/html5lib/inputstream.pyR5   ‡   s   	!					(		/R6   c           B` s\   e  Z d  Z d e e d „ Z d „  Z d „  Z e e d „ Z d „  Z	 d „  Z
 d „  Z RS(	   u×   Provides 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.

    c         C` sŽ   |  j  | ƒ |  _ t j |  |  j ƒ t | ƒ d f |  _ d |  _ d |  _ d |  _ |  j d d k r€ |  j
 | | ƒ |  _ n  |  j ƒ  d S(   u  Initialises 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)

        parseMeta - Look for a <meta> element containing encoding information

        u   certaini   id   u   windows-1252i    N(   RE   t	   rawStreamR5   R   t	   codecNameRD   t   numBytesMetat   numBytesChardett   defaultEncodingR3   t   detectEncodingRG   (   R   R7   R8   R9   R:   (    (    sG   /var/www/testScraper/venv/build/pip/pip/_vendor/html5lib/inputstream.pyR   x  s    			c         C` s6   t  j |  j d ƒ |  j d ƒ |  _ t j |  ƒ d  S(   Ni    u   replace(   t   codecst	   getreaderRD   Ry   RF   R5   RG   (   R   (    (    sG   /var/www/testScraper/venv/build/pip/pip/_vendor/html5lib/inputstream.pyRG      s    c         C` sU   t  | d ƒ r | } n t | ƒ } y | j | j ƒ  ƒ Wn t | ƒ } n X| S(   uv   Produces a file object from source.

        source can be either a file object, local filename or a string.

        u   read(   R1   R   R    R   R   (   R   R7   R   (    (    sG   /var/www/testScraper/venv/build/pip/pip/_vendor/html5lib/inputstream.pyRE   ¥  s    	c   
      C` s’  |  j  ƒ  } d } | d  k r9 | r9 |  j ƒ  } d } n  | d  k r8| r8d } yÐ y d d l m } Wn! t k
 r‹ d d l m } n Xg  } | ƒ  } x[ | j sø |  j j	 |  j
 ƒ } t | t ƒ sÑ t ‚ | sÛ Pn  | j | ƒ | j | ƒ qž W| j ƒ  | j d } |  j j d ƒ Wq8t k
 r4q8Xn  | d  k rVd } |  j } n  i d d 6}	 | j ƒ  |	 k rˆ|	 | j ƒ  } n  | | f S(   Nu   certainu	   tentativei    (   t   UniversalDetectoru   encodingu   windows-1252u
   iso-8859-1(   t	   detectBOMR3   t   detectEncodingMetat   charade.universaldetectorR�   t   ImportErrort   chardet.universaldetectort   doneRy   R$   R|   R2   R#   R   R'   t   feedt   closet   resultR    R}   t   lower(
   R   R9   R:   R8   t
   confidenceR�   t   bufferst   detectorR   t   encodingSub(    (    sG   /var/www/testScraper/venv/build/pip/pip/_vendor/html5lib/inputstream.pyR~   ¸  sB    		
c         C` sÀ   |  j  d d k s t ‚ t | ƒ } | d	 k r: d } n  | d  k rJ d  S| |  j  d k rv |  j  d d f |  _  nF |  j j d ƒ |  j ƒ  | d f |  _  t d |  j  d | f ƒ ‚ d  S(
   Ni   u   certainu   utf-16u	   utf-16-beu	   utf-16-leu   utf-8i    u   Encoding changed from %s to %s(   u   utf-16u	   utf-16-beu	   utf-16-le(   RD   R   Rz   R3   Ry   R    RG   R	   (   R   t   newEncoding(    (    sG   /var/www/testScraper/venv/build/pip/pip/_vendor/html5lib/inputstream.pyt   changeEncodingå  s    	
c         C` sØ   i d t  j 6d t  j 6d t  j 6d t  j 6d t  j 6} |  j j d ƒ } t | t	 ƒ s_ t
 ‚ | j | d  ƒ } d } | s¸ | j | ƒ } d } | s¸ | j | d  ƒ } d } q¸ n  |  j j | rÍ | pÐ d	 ƒ | S(
   u©   Attempts 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 Noneu   utf-8u	   utf-16-leu	   utf-16-beu	   utf-32-leu	   utf-32-bei   i   i   i    (   R   t   BOM_UTF8t   BOM_UTF16_LEt   BOM_UTF16_BEt   BOM_UTF32_LEt   BOM_UTF32_BERy   R$   R2   R#   R   t   getR    (   R   t   bomDictt   stringR8   R    (    (    sG   /var/www/testScraper/venv/build/pip/pip/_vendor/html5lib/inputstream.pyR‚   ô  s     
c         C` sk   |  j  j |  j ƒ } t | t ƒ s* t ‚ t | ƒ } |  j  j d ƒ | j ƒ  } | d k rg d } n  | S(   u9   Report the encoding declared by the meta element
        i    u   utf-16u	   utf-16-beu	   utf-16-leu   utf-8(   u   utf-16u	   utf-16-beu	   utf-16-le(	   Ry   R$   R{   R2   R#   R   t   EncodingParserR    t   getEncoding(   R   R   t   parserR8   (    (    sG   /var/www/testScraper/venv/build/pip/pip/_vendor/html5lib/inputstream.pyRƒ     s    	N(   R   R   R0   R3   R^   R   RG   RE   R~   R‘   R‚   Rƒ   (    (    (    sG   /var/www/testScraper/venv/build/pip/pip/_vendor/html5lib/inputstream.pyR6   p  s   (		-		t   EncodingBytesc           B` s¡   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 e e
 e	 ƒ Z d	 „  Z e e ƒ Z e d
 „ Z d „  Z d „  Z d „  Z RS(   u£   String-like object with an associated position and various extra methods
    If the position is ever greater than the string length then an exception is
    raisedc         C` s+   t  | t ƒ s t ‚ t j |  | j ƒ  ƒ S(   N(   R2   R#   R   t   __new__R‹   (   R   t   value(    (    sG   /var/www/testScraper/venv/build/pip/pip/_vendor/html5lib/inputstream.pyRž   &  s    c         C` s   d |  _  d  S(   Niÿÿÿÿ(   RT   (   R   RŸ   (    (    sG   /var/www/testScraper/venv/build/pip/pip/_vendor/html5lib/inputstream.pyR   *  s    c         C` s   |  S(   N(    (   R   (    (    sG   /var/www/testScraper/venv/build/pip/pip/_vendor/html5lib/inputstream.pyt   __iter__-  s    c         C` sS   |  j  d } |  _  | t |  ƒ k r/ t ‚ n | d k  rD t ‚ n  |  | | d !S(   Ni   i    (   RT   R   t   StopIterationR4   (   R   t   p(    (    sG   /var/www/testScraper/venv/build/pip/pip/_vendor/html5lib/inputstream.pyt   __next__0  s    		c         C` s
   |  j  ƒ  S(   N(   R£   (   R   (    (    sG   /var/www/testScraper/venv/build/pip/pip/_vendor/html5lib/inputstream.pyt   next8  s    c         C` sY   |  j  } | t |  ƒ k r$ t ‚ n | d k  r9 t ‚ n  | d |  _  } |  | | d !S(   Ni    i   (   RT   R   R¡   R4   (   R   R¢   (    (    sG   /var/www/testScraper/venv/build/pip/pip/_vendor/html5lib/inputstream.pyt   previous<  s    			c         C` s+   |  j  t |  ƒ k r t ‚ n  | |  _  d  S(   N(   RT   R   R¡   (   R   R   (    (    sG   /var/www/testScraper/venv/build/pip/pip/_vendor/html5lib/inputstream.pyt   setPositionE  s    	c         C` s<   |  j  t |  ƒ k r t ‚ n  |  j  d k r4 |  j  Sd  Sd  S(   Ni    (   RT   R   R¡   R3   (   R   (    (    sG   /var/www/testScraper/venv/build/pip/pip/_vendor/html5lib/inputstream.pyt   getPositionJ  s
    	c         C` s   |  |  j  |  j  d !S(   Ni   (   R   (   R   (    (    sG   /var/www/testScraper/venv/build/pip/pip/_vendor/html5lib/inputstream.pyt   getCurrentByteT  s    c         C` sc   |  j  } xJ | t |  ƒ k  rU |  | | d !} | | k rH | |  _ | S| d 7} q W| |  _ d S(   u   Skip past a list of charactersi   N(   R   R   RT   R3   (   R   Rr   R¢   Rs   (    (    sG   /var/www/testScraper/venv/build/pip/pip/_vendor/html5lib/inputstream.pyRi   Y  s    			c         C` sc   |  j  } xJ | t |  ƒ k  rU |  | | d !} | | k rH | |  _ | S| d 7} q W| |  _ d  S(   Ni   (   R   R   RT   R3   (   R   Rr   R¢   Rs   (    (    sG   /var/www/testScraper/venv/build/pip/pip/_vendor/html5lib/inputstream.pyt	   skipUntile  s    			c         C` sQ   |  j  } |  | | t | ƒ !} | j | ƒ } | rM |  j  t | ƒ 7_  n  | S(   uÓ   Look 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   t
   startswith(   R   R#   R¢   R(   R+   (    (    sG   /var/www/testScraper/venv/build/pip/pip/_vendor/html5lib/inputstream.pyt
   matchBytesp  s    	c         C` sh   |  |  j  j | ƒ } | d k r^ |  j d k r= d |  _ n  |  j | t | ƒ d 7_ t St ‚ d S(   u�   Look 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ÿÿÿÿi    i   N(   R   t   findRT   R   R^   R¡   (   R   R#   t   newPosition(    (    sG   /var/www/testScraper/venv/build/pip/pip/_vendor/html5lib/inputstream.pyt   jumpTo{  s    (   R   R   R0   Rž   R   R    R£   R¤   R¥   R¦   R§   t   propertyR   R¨   t   currentBytet   spaceCharactersBytesRi   R©   R«   R®   (    (    (    sG   /var/www/testScraper/venv/build/pip/pip/_vendor/html5lib/inputstream.pyR�   "  s    												Rš   c           B` s_   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d	 „  Z RS(
   u?   Mini parser for detecting character encoding from meta elementsc         C` s   t  | ƒ |  _ d |  _ d S(   u3   string - the data to work on for encoding detectionN(   R�   R(   R3   R8   (   R   R(   (    (    sG   /var/www/testScraper/venv/build/pip/pip/_vendor/html5lib/inputstream.pyR   Œ  s    c         C` sÎ   d |  j  f d |  j f d |  j f d |  j f d |  j f d |  j f f } xv |  j D]k } t } xR | D]J \ } } |  j j | ƒ rk y | ƒ  } PWqµ t k
 r± t	 } Pqµ Xqk qk W| sX PqX qX W|  j
 S(   Ns   <!--s   <metas   </s   <!s   <?R   (   t   handleCommentt
   handleMetat   handlePossibleEndTagt   handleOthert   handlePossibleStartTagR(   R^   R«   R¡   RZ   R8   (   R   t   methodDispatcht   bytet   keepParsingt   keyt   method(    (    sG   /var/www/testScraper/venv/build/pip/pip/_vendor/html5lib/inputstream.pyR›   ‘  s&    	c         C` s   |  j  j d ƒ S(   u   Skip over commentss   -->(   R(   R®   (   R   (    (    sG   /var/www/testScraper/venv/build/pip/pip/_vendor/html5lib/inputstream.pyR²   ¨  s    c         C` sK  |  j  j t k r t St } d  } x"t rF|  j ƒ  } | d  k rG t S| d d k r‰ | d d k } | rC| d  k	 rC| |  _ t Sq% | d d k rË | d } t | ƒ } | d  k	 rC| |  _ t Sq% | d d k r% t	 t
 | d ƒ ƒ } | j ƒ  } | d  k	 rCt | ƒ } | d  k	 r@| r4| |  _ t S| } q@qCq% q% Wd  S(   Ni    s
   http-equivi   s   content-typet   charsett   content(   R(   R°   R±   R^   RZ   R3   t   getAttributeR8   Rz   t   ContentAttrParserR�   t   parse(   R   t	   hasPragmat   pendingEncodingt   attrt   tentativeEncodingt   codect   contentParser(    (    sG   /var/www/testScraper/venv/build/pip/pip/_vendor/html5lib/inputstream.pyR³   ¬  s:    		
		c         C` s   |  j  t ƒ S(   N(   t   handlePossibleTagRZ   (   R   (    (    sG   /var/www/testScraper/venv/build/pip/pip/_vendor/html5lib/inputstream.pyR¶   Ð  s    c         C` s   t  |  j ƒ |  j t ƒ S(   N(   R¤   R(   RÇ   R^   (   R   (    (    sG   /var/www/testScraper/venv/build/pip/pip/_vendor/html5lib/inputstream.pyR´   Ó  s    c         C` s�   |  j  } | j t k r9 | r5 | j ƒ  |  j ƒ  n  t S| j t ƒ } | d k ra | j ƒ  n+ |  j ƒ  } x | d  k	 r‹ |  j ƒ  } qp Wt S(   NR   (
   R(   R°   t   asciiLettersBytesR¥   Rµ   R^   R©   t   spacesAngleBracketsR¾   R3   (   R   t   endTagR(   Rs   RÃ   (    (    sG   /var/www/testScraper/venv/build/pip/pip/_vendor/html5lib/inputstream.pyRÇ   ×  s    	
c         C` s   |  j  j d ƒ S(   NR   (   R(   R®   (   R   (    (    sG   /var/www/testScraper/venv/build/pip/pip/_vendor/html5lib/inputstream.pyRµ   î  s    c         C` s¾  |  j  } | j t t d g ƒ Bƒ } | d k sI t | ƒ d k sI t ‚ | d	 k rY d Sg  } g  } x¦ t r| d k r„ | r„ Pnz | t k r  | j ƒ  } Pn^ | d
 k r¿ d j | ƒ d f S| t	 k rá | j
 | j ƒ  ƒ n | d k rñ d S| j
 | ƒ t | ƒ } qh W| d k r7| j ƒ  d j | ƒ d f St | ƒ | j ƒ  } | d k rÜ| } xØ t rØt | ƒ } | | k r¦t | ƒ d j | ƒ d j | ƒ f S| t	 k rÈ| j
 | j ƒ  ƒ qb| j
 | ƒ qbWn^ | d k rûd j | ƒ d f S| t	 k r| j
 | j ƒ  ƒ n | d k r-d S| j
 | ƒ x} t r¹t | ƒ } | t k rwd j | ƒ d j | ƒ f S| t	 k r™| j
 | j ƒ  ƒ q=| d k r©d S| j
 | ƒ q=Wd S(   u_   Return a name,value pair for the next attribute in the stream,
        if one is found, or Nonet   /i   R   t   =t    t   't   "N(   R   N(   RË   R   (   RÎ   RÏ   (   R(   Ri   R±   t	   frozensetR3   R   R   R^   R)   t   asciiUppercaseBytesR'   R‹   R¤   R¥   RÉ   (   R   R(   Rs   t   attrNamet	   attrValuet	   quoteChar(    (    sG   /var/www/testScraper/venv/build/pip/pip/_vendor/html5lib/inputstream.pyR¾   ñ  sh    	$	

	
	(   R   R   R0   R   R›   R²   R³   R¶   R´   RÇ   Rµ   R¾   (    (    (    sG   /var/www/testScraper/venv/build/pip/pip/_vendor/html5lib/inputstream.pyRš   ‰  s   				$				R¿   c           B` s   e  Z d  „  Z d „  Z RS(   c         C` s"   t  | t ƒ s t ‚ | |  _ d  S(   N(   R2   R#   R   R(   (   R   R(   (    (    sG   /var/www/testScraper/venv/build/pip/pip/_vendor/html5lib/inputstream.pyR   ?  s    c         C` s:  y!|  j  j d ƒ |  j  j d 7_ |  j  j ƒ  |  j  j d k sH d  S|  j  j d 7_ |  j  j ƒ  |  j  j d k rÐ |  j  j } |  j  j d 7_ |  j  j } |  j  j | ƒ rÉ |  j  | |  j  j !Sd  SnP |  j  j } y( |  j  j t ƒ |  j  | |  j  j !SWn t k
 r|  j  | SXWn t k
 r5d  SXd  S(   NR¼   i   RÌ   RÏ   RÎ   (   RÏ   RÎ   (	   R(   R®   R   Ri   R°   R3   R©   R±   R¡   (   R   t	   quoteMarkt   oldPosition(    (    sG   /var/www/testScraper/venv/build/pip/pip/_vendor/html5lib/inputstream.pyRÀ   C  s.    (   R   R   R   RÀ   (    (    (    sG   /var/www/testScraper/venv/build/pip/pip/_vendor/html5lib/inputstream.pyR¿   >  s   	c         C` sp   t  |  t ƒ r: y |  j d ƒ }  Wq: t k
 r6 d SXn  |  rh t j d |  ƒ j ƒ  } t j	 | d ƒ Sd Sd S(   u{   Return the python codec name corresponding to an encoding or None if the
    string doesn't correspond to a valid encoding.u   asciiu    N(
   R2   R#   t   decodet   UnicodeDecodeErrorR3   t   ascii_punctuation_reR\   R‹   R   R—   (   R8   t   canonicalName(    (    sG   /var/www/testScraper/venv/build/pip/pip/_vendor/html5lib/inputstream.pyRz   e  s    (    (    (/   t
   __future__R    R   R   t   pip._vendor.sixR   R   R?   t	   constantsR   R   R   R   R   R	   RÍ   R
   t   ioR   R   R…   R   t   objectRÐ   R&   t   encodeR±   RÈ   RÑ   RÉ   R@   Ra   t   setRh   RÙ   Rm   R   R3   R^   R<   R5   R6   R#   R�   Rš   R¿   Rz   (    (    (    sG   /var/www/testScraper/venv/build/pip/pip/_vendor/html5lib/inputstream.pyt   <module>   sJ   "
(((Jé²gµ'