î
ìÎR\m	  ã               @   s§   d  d l  m Z m Z m Z d  d l m Z y d  d l j j Z	 Wn$ e
 k
 rh d  d l j j Z	 Yn XGd d „  d e ƒ Z d d „  Z d d	 „  Z d
 d „  Z d S)é    )Úabsolute_importÚdivisionÚunicode_literals)Ú
ModuleTypeNc               @   s1   e  Z d  Z d Z f  d d „ Z d d „  Z d S)ÚMethodDispatcherap  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  } xl | D]d \ } } t  | ƒ t t t t f k r^ x7 | D] } | j | | f ƒ q> Wq | j | | f ƒ q Wt j |  | ƒ d  |  _ d  S)N)	ÚtypeÚlistÚtupleÚ	frozensetÚsetÚappendÚdictÚ__init__Údefault)ÚselfÚitemsÚ_dictEntriesÚnameÚvalueÚitem© r   ú=/var/www/dbchiro/venv/build/pip/pip/_vendor/html5lib/utils.pyr      s    zMethodDispatcher.__init__c             C   s   t  j |  | |  j ƒ S)N)r   Úgetr   )r   Úkeyr   r   r   Ú__getitem__&   s    zMethodDispatcher.__getitem__N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   r   r      s   r   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)Né   r   i Ø  iÿÛ  é   i Ü  iÿß  )ÚlenÚord)Údatar   r   r   ÚisSurrogatePair-   s    ,r$   c             C   s2   d t  |  d ƒ d d t  |  d ƒ d } | S)Ni   r   i Ø  i   r    i Ü  )r"   )r#   Úchar_valr   r   r   ÚsurrogatePairToCodepoint3   s    r&   c                s   i  ‰ ‡  ‡ f d d †  } | S)Nc                s‰   t  t j t d ƒ ƒ r( d |  j } n d |  j } | ˆ k rI ˆ | St | ƒ } ˆ  |  | | Ž } | j j | ƒ | ˆ | <| Sd  S)NÚ z_%s_factorys   _%s_factory)Ú
isinstancer   r   r   Ú__dict__Úupdate)Ú
baseModuleÚargsÚkwargsr   ÚmodÚobjs)ÚfactoryÚmoduleCacher   r   ÚmoduleFactory?   s    
z+moduleFactoryFactory.<locals>.moduleFactoryr   )r0   r2   r   )r0   r1   r   ÚmoduleFactoryFactory<   s    r3   )Ú
__future__r   r   r   Útypesr   Úxml.etree.cElementTreeÚetreeÚcElementTreeÚdefault_etreeÚImportErrorÚxml.etree.ElementTreeÚElementTreer   r   r$   r&   r3   r   r   r   r   Ú<module>   s   "	