ó
äq™^c           @` s'  d  d l  m Z m Z m Z d  d l m Z d  d l m Z y d  d l j	 j
 Z Wn# e k
 rw 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 Z n Xe Z 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	   text_typeNu   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 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-aSgKnK/pip/pip/_vendor/html5lib/_utils.pyR   1   s    c         C` s   t  j |  | |  j ƒ S(   N(   R   t   getR   (   R   t   key(    (    s8   /tmp/pip-build-aSgKnK/pip/pip/_vendor/html5lib/_utils.pyt   __getitem__@   s    (    (   t   __name__t
   __module__t   __doc__R   R   (    (    (    s8   /tmp/pip-build-aSgKnK/pip/pip/_vendor/html5lib/_utils.pyR   $   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-aSgKnK/pip/pip/_vendor/html5lib/_utils.pyt   isSurrogatePairG   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-aSgKnK/pip/pip/_vendor/html5lib/_utils.pyt   surrogatePairToCodepointM   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-aSgKnK/pip/pip/_vendor/html5lib/_utils.pyt   moduleFactoryY   s$    (    (   R-   R/   (    (   R-   R.   s8   /tmp/pip-build-aSgKnK/pip/pip/_vendor/html5lib/_utils.pyt   moduleFactoryFactoryV   s    c         ` s   i  ‰  ‡  ‡ f d †  } | S(   Nc          ` sH   t  |  ƒ t  | j ƒ  ƒ f } | ˆ  k r@ ˆ |  | Ž  ˆ  | <n  ˆ  | S(   N(   R   R   (   R(   R)   R   (   t   cachet   func(    s8   /tmp/pip-build-aSgKnK/pip/pip/_vendor/html5lib/_utils.pyt   wrappedv   s    (    (   R2   R3   (    (   R1   R2   s8   /tmp/pip-build-aSgKnK/pip/pip/_vendor/html5lib/_utils.pyt   memoizes   s    (   t
   __future__R    R   R   t   typesR   t   pip._vendor.sixR   t   xml.etree.cElementTreet   etreet   cElementTreet   default_etreet   ImportErrort   xml.etree.ElementTreet   ElementTreet   __all__t   evalt   _xR   R   t   Falset   supports_lone_surrogatest   TrueR   R   R    R"   R0   R4   (    (    (    s8   /tmp/pip-build-aSgKnK/pip/pip/_vendor/html5lib/_utils.pyt   <module>   s,   			
#				