ó
Ð²Ebc           @` s   d  d l  m Z m Z m Z d  d l m Z y d  d l m Z Wn! e k
 rc d  d l	 m Z n Xd  d l
 m Z m Z e r• d  d l j j Z n< y d  d l j j Z Wn# e k
 rÐ d  d l j j Z n Xd d d d	 d
 d g Z yC e d ƒ Z e e e ƒ s+e d ƒ Z e e e ƒ s+t ‚ n  Wn e k
 rEe Z n Xe Z d e f d „  ƒ  YZ d e f d „  ƒ  YZ d „  Z d „  Z  d „  Z! d „  Z" d S(   i    (   t   absolute_importt   divisiont   unicode_literals(   t
   ModuleType(   t   Mapping(   t	   text_typet   PY3Nu   default_etreeu   MethodDispatcheru   isSurrogatePairu   surrogatePairToCodepointu   moduleFactoryFactoryu   supports_lone_surrogatesu   "\uD800"u	   u"\uD800"t   MethodDispatcherc           B` s/   e  Z d  Z d d „ Z d „  Z d d „ Z RS(   up  Dict with 2 special properties:

    On initiation, keys that are lists, sets or tuples are converted to
    multiple keys so accessing any one of the items in the original
    list-like object returns the matching value

    md = MethodDispatcher({("foo", "bar"):"baz"})
    md["foo"] == "baz"

    A default value which can be set through the default attribute.
    c         C` s­   g  } xi | D]a \ } } t  | t t t t f ƒ r[ x7 | D] } | j | | f ƒ q; Wq | j | | f ƒ q Wt j |  | ƒ t |  ƒ t | ƒ k s  t	 ‚ d  |  _ d  S(   N(   t
   isinstancet   listt   tuplet	   frozensett   sett   appendt   dictt   __init__t   lent   AssertionErrort   Nonet   default(   t   selft   itemst   _dictEntriest   namet   valuet   item(    (    s8   /tmp/pip-build-UPPWic/pip/pip/_vendor/html5lib/_utils.pyR   9   s    c         C` s   t  j |  | |  j ƒ S(   N(   R   t   getR   (   R   t   key(    (    s8   /tmp/pip-build-UPPWic/pip/pip/_vendor/html5lib/_utils.pyt   __getitem__E   s    c         C` s   t  | |  ƒ S(   N(   t   BoundMethodDispatcher(   R   t   instancet   owner(    (    s8   /tmp/pip-build-UPPWic/pip/pip/_vendor/html5lib/_utils.pyt   __get__H   s    (    N(   t   __name__t
   __module__t   __doc__R   R   R   R    (    (    (    s8   /tmp/pip-build-UPPWic/pip/pip/_vendor/html5lib/_utils.pyR   ,   s   	R   c           B` sD   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   uA   Wraps a MethodDispatcher, binding its return values to `instance`c         C` s   | |  _  | |  _ d  S(   N(   R   t
   dispatcher(   R   R   R$   (    (    s8   /tmp/pip-build-UPPWic/pip/pip/_vendor/html5lib/_utils.pyR   N   s    	c         C` s   |  j  | j |  j ƒ S(   N(   R$   R    R   (   R   R   (    (    s8   /tmp/pip-build-UPPWic/pip/pip/_vendor/html5lib/_utils.pyR   R   s    c         C` s   | |  j  k r |  | S| Sd  S(   N(   R$   (   R   R   R   (    (    s8   /tmp/pip-build-UPPWic/pip/pip/_vendor/html5lib/_utils.pyR   W   s    c         C` s   t  |  j ƒ S(   N(   t   iterR$   (   R   (    (    s8   /tmp/pip-build-UPPWic/pip/pip/_vendor/html5lib/_utils.pyt   __iter__]   s    c         C` s   t  |  j ƒ S(   N(   R   R$   (   R   (    (    s8   /tmp/pip-build-UPPWic/pip/pip/_vendor/html5lib/_utils.pyt   __len__`   s    c         C` s   | |  j  k S(   N(   R$   (   R   R   (    (    s8   /tmp/pip-build-UPPWic/pip/pip/_vendor/html5lib/_utils.pyt   __contains__c   s    (	   R!   R"   R#   R   R   R   R&   R'   R(   (    (    (    s8   /tmp/pip-build-UPPWic/pip/pip/_vendor/html5lib/_utils.pyR   L   s   					c         C` sh   t  |  ƒ d k og t |  d ƒ d k og t |  d ƒ d k og t |  d ƒ d k og t |  d ƒ d k S(   Ni   i    i Ø  iÿÛ  i   i Ü  iÿß  (   R   t   ord(   t   data(    (    s8   /tmp/pip-build-UPPWic/pip/pip/_vendor/html5lib/_utils.pyt   isSurrogatePairj   s    ,c         C` s2   d t  |  d ƒ d d t  |  d ƒ d } | S(   Ni   i    i Ø  i   i   i Ü  (   R)   (   R*   t   char_val(    (    s8   /tmp/pip-build-UPPWic/pip/pip/_vendor/html5lib/_utils.pyt   surrogatePairToCodepointp   s    c         ` s   i  ‰ ‡  ‡ f d †  } | S(   Nc         ` s  t  t j t d ƒ ƒ r( d |  j } n d |  j } t | j ƒ  ƒ } y ˆ | | | SWnµ t k
 rt | ƒ } ˆ  |  | | Ž } | j j | ƒ d ˆ k r² i  ˆ | <n  d ˆ | k rÓ i  ˆ | | <n  d ˆ | | k rü i  ˆ | | | <n  | ˆ | | | <| SXd  S(   Nu    u   _%s_factorys   _%s_factoryu   nameu   argsu   kwargs(	   R   R   R!   t   typeR
   R   t   KeyErrort   __dict__t   update(   t
   baseModulet   argst   kwargsR   t   kwargs_tuplet   modt   objs(   t   factoryt   moduleCache(    s8   /tmp/pip-build-UPPWic/pip/pip/_vendor/html5lib/_utils.pyt   moduleFactory|   s$    (    (   R8   R:   (    (   R8   R9   s8   /tmp/pip-build-UPPWic/pip/pip/_vendor/html5lib/_utils.pyt   moduleFactoryFactoryy   s    c         ` s   i  ‰  ‡  ‡ f d †  } | S(   Nc          ` sH   t  |  ƒ t  | j ƒ  ƒ f } | ˆ  k r@ ˆ |  | Ž  ˆ  | <n  ˆ  | S(   N(   R
   R   (   R3   R4   R   (   t   cachet   func(    s8   /tmp/pip-build-UPPWic/pip/pip/_vendor/html5lib/_utils.pyt   wrapped™   s    (    (   R=   R>   (    (   R<   R=   s8   /tmp/pip-build-UPPWic/pip/pip/_vendor/html5lib/_utils.pyt   memoize–   s    (#   t
   __future__R    R   R   t   typesR   t   collections.abcR   t   ImportErrort   collectionst   pip._vendor.sixR   R   t   xml.etree.ElementTreet   etreet   ElementTreet   default_etreet   xml.etree.cElementTreet   cElementTreet   __all__t   evalt   _xR   R   t	   Exceptiont   Falset   supports_lone_surrogatest   TrueR   R   R   R+   R-   R;   R?   (    (    (    s8   /tmp/pip-build-UPPWic/pip/pip/_vendor/html5lib/_utils.pyt   <module>   s:   			
 				