B
    =)H[¦  ã               @   sB  d dl mZ d dlZd dlZd dlZyd dlZW n ek
rH   dZY nX ejd  dk �r~d dlmZ e	fZ
eZd dlmZ d dlZd dlZddlmZ d dlmZmZmZmZmZ d d	lmZmZmZm Z m!Z!m"Z"m#Z# d
d„ Zd dl$Z$d dl$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z- e�r&d dl$m.Z. d dl/Z/d dl0Z0d dl1Z2d dl3m3Z3 d dl4Z4e5Z5d dl6m7Z8 d dl6m9Z: da;dd„ Z<�nd dl=mZ e>fZ
e>Zd dl=m?Z d dlZd dlZd dlZd dl@mZmZmZm<Z<mZmZmZmZm#Z# d dlAm&Z&mZm%Z%m Z m!Z!m)Z)m*Z*m+Z+m,Z,m-Z- e�r&d dlAm.Z. d dlBm(Z(m'Z'm"Z" d dlCmDZ/ d dlAmEZ$ d dlFmDZ0 d dl2Z2d dlGm3Z3 d dlHmIZ4 eJZ5d dl6m:Z: e8Z8yd dlmKZKmLZL W n8 ek
�rÞ   G dd„ deMƒZLdddd„ZNdd„ ZKY nX yd dlmOZP W n& ek
�r   G d d!„ d!eQƒZPY nX yd d"lmRZR W n, ek
�rT   ejSejTB dfd#d$„ZRY nX d d%lUmVZW eXeWd&ƒ�rteWZVn,d d'lUmYZZ G d(d)„ d)eZƒZYG d*d+„ d+eWƒZVyd d,l[m\Z\ W n ek
�rÎ   d-d.„ Z\Y nX yd dl]Z]W n" ek
�rþ   dd/lm]Z] Y nX ye^Z^W n* e_k
�r2   d d0l`maZa d1d2„ Z^Y nX yejbZbejcZcW nH edk
�rŒ   e e¡ �pbd3Zfefd4k�rtd5Zgnd6Zgd7d8„ Zbd9d:„ ZcY nX yd d;lhmiZi W nH ek
�ræ   d d<ljmkZkmlZl d dlZe md=¡Znd>d?„ Zod@dA„ ZiY nX yd dBlpmqZq W n" ek
�r   d dBlrmqZq Y nX ejddC… dDk �r:e3ƒ jsZsnd dElpmsZs yd dFl`mtZt W nd ek
�rº   d dGl`muZu yd dHlvmwZx W n  ek
�r¤   dedJdK„ZxY nX G dLdM„ dMeuƒZtY nX yd dNlymzZz W nH ek
�r   yd dNl{mzZz W n  ek
�r   dfdOdP„ZzY nX Y nX yd dQl`m|Z| W nŠ ek
�r°   yd dRl}m~Z W n" ek
�rj   d dRl€m~Z Y nX yd dSl�m‚Z‚mƒZƒm„Z„ W n ek
�rš   Y nX G dTdU„ dUe…ƒZ|Y nX yd dVl†m‡Z‡mˆZˆ W nv ek
�r<   e mdWej‰¡ZŠdXdY„ ZˆG dZd[„ d[e…ƒZ‹dgd\d]„ZŒG d^d_„ d_e�ƒZŽG d`da„ dae�ƒZ�G dbdc„ dceQƒZ‡Y nX dS )hé    )Úabsolute_importNé   )ÚStringIO)ÚFileTypeé   )Úshutil)ÚurlparseÚ
urlunparseÚurljoinÚurlsplitÚ
urlunsplit)ÚurlretrieveÚquoteÚunquoteÚurl2pathnameÚpathname2urlÚContentTooShortErrorÚ	splittypec             C   s   t | tƒr|  d¡} t| ƒS )Nzutf-8)Ú
isinstanceÚunicodeÚencodeÚ_quote)Ús© r   ú[C:\Users\HIRONO~1\AppData\Local\Temp\pip-install-qz7kpjmn\pip\pip\_vendor\distlib\compat.pyr      s    

r   )	ÚRequestÚurlopenÚURLErrorÚ	HTTPErrorÚHTTPBasicAuthHandlerÚHTTPPasswordMgrÚHTTPHandlerÚHTTPRedirectHandlerÚbuild_opener)ÚHTTPSHandler)Ú
HTMLParser)Úifilter)Úifilterfalsec             C   s<   t dkrddl}| d¡a t  | ¡}|r4| dd¡S d| fS )zJsplituser('user[:passwd]@host[:port]') --> 'user[:passwd]', 'host[:port]'.Nr   z^(.*)@(.*)$r   é   )Ú	_userprogÚreÚcompileÚmatchÚgroup)Úhostr*   r,   r   r   r   Ú	splituser4   s    

 r/   )ÚTextIOWrapper)	r   r	   r
   r/   r   r   r   r   r   )
r   r   r   r   r   r   r    r!   r"   r#   )r   r   r   )Úfilterfalse)Úmatch_hostnameÚCertificateErrorc               @   s   e Zd ZdS )r3   N)Ú__name__Ú
__module__Ú__qualname__r   r   r   r   r3   ^   s   r3   c       
      C   sø   g }| sdS |   d¡}|d |dd…  }}| d¡}||krNtdt| ƒ ƒ‚|sb|  ¡ | ¡ kS |dkrv| d¡ n>| d	¡sŠ| d	¡rœ| t |¡¡ n| t |¡ 	d
d¡¡ x|D ]}| t |¡¡ qºW t 
dd |¡ d tj¡}	|	 |¡S )zpMatching according to RFC 6125, section 6.4.3

        http://tools.ietf.org/html/rfc6125#section-6.4.3
        FÚ.r   r   NÚ*z,too many wildcards in certificate DNS name: z[^.]+zxn--z\*z[^.]*z\Az\.z\Z)ÚsplitÚcountr3   ÚreprÚlowerÚappendÚ
startswithr*   ÚescapeÚreplacer+   ÚjoinÚ
IGNORECASEr,   )
ÚdnÚhostnameZmax_wildcardsZpatsÚpartsZleftmostÚ	remainderÚ	wildcardsÚfragÚpatr   r   r   Ú_dnsname_matchb   s(    


rJ   c             C   sò   | st dƒ‚g }|  dd¡}x0|D ](\}}|dkr"t||ƒr@dS | |¡ q"W |sšxF|  dd¡D ]6}x0|D ](\}}|dkrjt||ƒrˆdS | |¡ qjW q`W t|ƒdkrÄtd	|d
 tt|ƒ¡f ƒ‚n*t|ƒdkrætd||d f ƒ‚ntdƒ‚dS )a=  Verify that *cert* (in decoded format as returned by
        SSLSocket.getpeercert()) matches the *hostname*.  RFC 2818 and RFC 6125
        rules are followed, but IP addresses are not accepted for *hostname*.

        CertificateError is raised on failure. On success, the function
        returns nothing.
        ztempty or no certificate, match_hostname needs a SSL socket or SSL context with either CERT_OPTIONAL or CERT_REQUIREDÚsubjectAltNamer   ÚDNSNÚsubjectÚ
commonNamer   z&hostname %r doesn't match either of %sz, zhostname %r doesn't match %rr   z=no appropriate commonName or subjectAltName fields were found)	Ú
ValueErrorÚgetrJ   r=   Úlenr3   rA   Úmapr;   )ÚcertrD   ÚdnsnamesÚsanÚkeyÚvalueÚsubr   r   r   r2   ”   s.    

r2   )ÚSimpleNamespacec               @   s   e Zd ZdZdd„ ZdS )Ú	ContainerzR
        A generic container for when multiple values need to be returned
        c             K   s   | j  |¡ d S )N)Ú__dict__Úupdate)ÚselfÚkwargsr   r   r   Ú__init__Æ   s    zContainer.__init__N)r4   r5   r6   Ú__doc__r_   r   r   r   r   rZ   Â   s   rZ   )Úwhichc                s"  dd„ }t j ˆ ¡r&|ˆ |ƒr"ˆ S dS |dkr>t j dt j¡}|sFdS | t j¡}tj	dkr¼t j
|krt| dt j
¡ t j dd¡ t j¡}t‡ fd	d
„|D ƒƒr¨ˆ g}qÂ‡ fdd„|D ƒ}nˆ g}tƒ }xT|D ]L}t j |¡}||krÎ| |¡ x(|D ] }	t j ||	¡}
||
|ƒrö|
S qöW qÎW dS )aK  Given a command, mode, and a PATH string, return the path which
        conforms to the given mode on the PATH, or None if there is no such
        file.

        `mode` defaults to os.F_OK | os.X_OK. `path` defaults to the result
        of os.environ.get("PATH"), or can be overridden with a custom search
        path.

        c             S   s&   t j | ¡o$t  | |¡o$t j | ¡ S )N)ÚosÚpathÚexistsÚaccessÚisdir)ÚfnÚmoder   r   r   Ú_access_checkÛ   s    zwhich.<locals>._access_checkNÚPATHÚwin32r   ÚPATHEXTÚ c             3   s    | ]}ˆ   ¡  |  ¡ ¡V  qd S )N)r<   Úendswith)Ú.0Úext)Úcmdr   r   ú	<genexpr>ø   s    zwhich.<locals>.<genexpr>c                s   g | ]}ˆ | ‘qS r   r   )ro   rp   )rq   r   r   ú
<listcomp>û   s    zwhich.<locals>.<listcomp>)rb   rc   ÚdirnameÚenvironrP   Údefpathr9   ÚpathsepÚsysÚplatformÚcurdirÚinsertÚanyÚsetÚnormcaseÚaddrA   )rq   rh   rc   ri   ÚpathextÚfilesÚseenÚdirÚnormdirÚthefileÚnamer   )rq   r   ra   Î   s8    






ra   )ÚZipFileÚ	__enter__)Ú
ZipExtFilec               @   s$   e Zd Zdd„ Zdd„ Zdd„ ZdS )r‰   c             C   s   | j  |j ¡ d S )N)r[   r\   )r]   Úbaser   r   r   r_     s    zZipExtFile.__init__c             C   s   | S )Nr   )r]   r   r   r   rˆ     s    zZipExtFile.__enter__c             G   s   |   ¡  d S )N)Úclose)r]   Úexc_infor   r   r   Ú__exit__  s    zZipExtFile.__exit__N)r4   r5   r6   r_   rˆ   r�   r   r   r   r   r‰     s   r‰   c               @   s$   e Zd Zdd„ Zdd„ Zdd„ ZdS )r‡   c             C   s   | S )Nr   )r]   r   r   r   rˆ   "  s    zZipFile.__enter__c             G   s   |   ¡  d S )N)r‹   )r]   rŒ   r   r   r   r�   %  s    zZipFile.__exit__c             O   s   t j| f|ž|Ž}t|ƒS )N)ÚBaseZipFileÚopenr‰   )r]   Úargsr^   rŠ   r   r   r   r�   )  s    zZipFile.openN)r4   r5   r6   rˆ   r�   r�   r   r   r   r   r‡   !  s   r‡   )Úpython_implementationc               C   s0   dt jkrdS tjdkrdS t j d¡r,dS dS )z6Return a string identifying the Python implementation.ÚPyPyÚjavaÚJythonÚ
IronPythonÚCPython)rx   Úversionrb   r†   r>   r   r   r   r   r‘   0  s    

r‘   )Ú	sysconfig)ÚCallablec             C   s
   t | tƒS )N)r   r™   )Úobjr   r   r   ÚcallableD  s    r›   zutf-8ÚmbcsÚstrictÚsurrogateescapec             C   s:   t | tƒr| S t | tƒr$|  tt¡S tdt| ƒj ƒ‚d S )Nzexpect bytes or str, not %s)	r   ÚbytesÚ	text_typer   Ú_fsencodingÚ	_fserrorsÚ	TypeErrorÚtyper4   )Úfilenamer   r   r   ÚfsencodeX  s    

r¦   c             C   s:   t | tƒr| S t | tƒr$|  tt¡S tdt| ƒj ƒ‚d S )Nzexpect bytes or str, not %s)	r   r    rŸ   Údecoder¡   r¢   r£   r¤   r4   )r¥   r   r   r   Úfsdecodea  s    

r¨   )Údetect_encoding)ÚBOM_UTF8Úlookupzcoding[:=]\s*([-\w.]+)c             C   sH   | dd…   ¡  dd¡}|dks*| d¡r.dS |dks@| d¡rDd	S | S )
z(Imitates get_normal_name in tokenizer.c.Né   Ú_ú-zutf-8zutf-8-)zlatin-1z
iso-8859-1ziso-latin-1)zlatin-1-ziso-8859-1-ziso-latin-1-z
iso-8859-1)r<   r@   r>   )Úorig_encÚencr   r   r   Ú_get_normal_namer  s    
r±   c                sÊ   yˆj j‰W n tk
r$   d‰Y nX d‰ d}d}‡fdd„}‡ ‡fdd„}|ƒ }| t¡rpd‰ |d	d… }d
}|s||g fS ||ƒ}|r’||gfS |ƒ }|s¦||gfS ||ƒ}|r¾|||gfS |||gfS )a?  
        The detect_encoding() function is used to detect the encoding that should
        be used to decode a Python source file.  It requires one argument, readline,
        in the same way as the tokenize() generator.

        It will call readline a maximum of twice, and return the encoding used
        (as a string) and a list of any lines (left as bytes) it has read in.

        It detects the encoding from the presence of a utf-8 bom or an encoding
        cookie as specified in pep-0263.  If both a bom and a cookie are present,
        but disagree, a SyntaxError will be raised.  If the encoding cookie is an
        invalid charset, raise a SyntaxError.  Note that if a utf-8 bom is found,
        'utf-8-sig' is returned.

        If no encoding is specified, then the default of 'utf-8' will be returned.
        NFzutf-8c                  s    yˆ ƒ S  t k
r   dS X d S )Nó    )ÚStopIterationr   )Úreadliner   r   Úread_or_stop•  s    z%detect_encoding.<locals>.read_or_stopc                sä   y|   d¡}W n4 tk
rB   d}ˆd k	r6d |ˆ¡}t|ƒ‚Y nX t |¡}|sVd S t|d ƒ}yt|ƒ}W n: tk
r¨   ˆd kr�d| }nd ˆ|¡}t|ƒ‚Y nX ˆ rà|j	dkrØˆd krÆd}n
d ˆ¡}t|ƒ‚|d	7 }|S )
Nzutf-8z'invalid or missing encoding declarationz{} for {!r}r   zunknown encoding: zunknown encoding for {!r}: {}zencoding problem: utf-8z encoding problem for {!r}: utf-8z-sig)
r§   ÚUnicodeDecodeErrorÚformatÚSyntaxErrorÚ	cookie_reÚfindallr±   r«   ÚLookupErrorr†   )ÚlineÚline_stringÚmsgÚmatchesÚencodingÚcodec)Ú	bom_foundr¥   r   r   Úfind_cookie›  s6    



z$detect_encoding.<locals>.find_cookieTr   z	utf-8-sig)Ú__self__r†   ÚAttributeErrorr>   rª   )r´   rÀ   Údefaultrµ   rÃ   ÚfirstÚsecondr   )rÂ   r¥   r´   r   r©   }  s4    
&


r©   )r?   r(   )r   é   )Úunescape)ÚChainMap)ÚMutableMapping)Úrecursive_reprú...c                s   ‡ fdd„}|S )zm
            Decorator to make a repr function return fillvalue for a recursive
            call
            c                sL   t ƒ ‰ ‡‡ ‡fdd„}tˆdƒ|_tˆdƒ|_tˆdƒ|_tˆdi ƒ|_|S )Nc          	      sB   t | ƒtƒ f}|ˆkrˆ S ˆ |¡ zˆ| ƒ}W d ˆ |¡ X |S )N)ÚidÚ	get_identr   Údiscard)r]   rV   Úresult)Ú	fillvalueÚrepr_runningÚuser_functionr   r   Úwrapperò  s    
z=_recursive_repr.<locals>.decorating_function.<locals>.wrapperr5   r`   r4   Ú__annotations__)r}   Úgetattrr5   r`   r4   r×   )rÕ   rÖ   )rÓ   )rÔ   rÕ   r   Údecorating_functionï  s    z,_recursive_repr.<locals>.decorating_functionr   )rÓ   rÙ   r   )rÓ   r   Ú_recursive_repré  s    rÚ   c               @   s´   e Zd ZdZdd„ Zdd„ Zdd„ Zd'd	d
„Zdd„ Zdd„ Z	dd„ Z
dd„ Zeƒ dd„ ƒZedd„ ƒZdd„ ZeZdd„ Zedd„ ƒZdd„ Zdd „ Zd!d"„ Zd#d$„ Zd%d&„ ZdS )(rË   aÍ   A ChainMap groups multiple dicts (or other mappings) together
        to create a single, updateable view.

        The underlying mappings are stored in a list.  That list is public and can
        accessed or updated using the *maps* attribute.  There is no other state.

        Lookups search the underlying mappings successively until a key is found.
        In contrast, writes, updates, and deletions only operate on the first
        mapping.

        c             G   s   t |ƒpi g| _dS )z˜Initialize a ChainMap by setting *maps* to the given mappings.
            If no mappings are provided, a single empty dictionary is used.

            N)ÚlistÚmaps)r]   rÜ   r   r   r   r_     s    zChainMap.__init__c             C   s   t |ƒ‚d S )N)ÚKeyError)r]   rV   r   r   r   Ú__missing__  s    zChainMap.__missing__c          	   C   s8   x,| j D ]"}y|| S  tk
r(   Y qX qW |  |¡S )N)rÜ   rÝ   rÞ   )r]   rV   Úmappingr   r   r   Ú__getitem__  s    
zChainMap.__getitem__Nc             C   s   || kr| | S |S )Nr   )r]   rV   rÆ   r   r   r   rP   %  s    zChainMap.getc             C   s   t tƒ j| jŽ ƒS )N)rQ   r}   ÚunionrÜ   )r]   r   r   r   Ú__len__(  s    zChainMap.__len__c             C   s   t tƒ j| jŽ ƒS )N)Úiterr}   rá   rÜ   )r]   r   r   r   Ú__iter__+  s    zChainMap.__iter__c                s   t ‡ fdd„| jD ƒƒS )Nc             3   s   | ]}ˆ |kV  qd S )Nr   )ro   Úm)rV   r   r   rr   /  s    z(ChainMap.__contains__.<locals>.<genexpr>)r|   rÜ   )r]   rV   r   )rV   r   Ú__contains__.  s    zChainMap.__contains__c             C   s
   t | jƒS )N)r|   rÜ   )r]   r   r   r   Ú__bool__1  s    zChainMap.__bool__c             C   s   d  | d tt| jƒ¡¡S )Nz{0.__class__.__name__}({1})z, )r·   rA   rR   r;   rÜ   )r]   r   r   r   Ú__repr__4  s    zChainMap.__repr__c             G   s   | t j|f|žŽ ƒS )z?Create a ChainMap with a single dict created from the iterable.)ÚdictÚfromkeys)ÚclsÚiterabler�   r   r   r   rê   9  s    zChainMap.fromkeysc             C   s$   | j | jd  ¡ f| jdd… žŽ S )zHNew ChainMap or subclass with a new copy of maps[0] and refs to maps[1:]r   r   N)Ú	__class__rÜ   Úcopy)r]   r   r   r   rî   >  s    zChainMap.copyc             C   s   | j i f| jžŽ S )z;New ChainMap with a new dict followed by all previous maps.)rí   rÜ   )r]   r   r   r   Ú	new_childD  s    zChainMap.new_childc             C   s   | j | jdd… Ž S )zNew ChainMap from maps[1:].r   N)rí   rÜ   )r]   r   r   r   ÚparentsH  s    zChainMap.parentsc             C   s   || j d |< d S )Nr   )rÜ   )r]   rV   rW   r   r   r   Ú__setitem__M  s    zChainMap.__setitem__c             C   s8   y| j d |= W n" tk
r2   td |¡ƒ‚Y nX d S )Nr   z(Key not found in the first mapping: {!r})rÜ   rÝ   r·   )r]   rV   r   r   r   Ú__delitem__P  s    zChainMap.__delitem__c             C   s0   y| j d  ¡ S  tk
r*   tdƒ‚Y nX dS )zPRemove and return an item pair from maps[0]. Raise KeyError is maps[0] is empty.r   z#No keys found in the first mapping.N)rÜ   ÚpopitemrÝ   )r]   r   r   r   ró   V  s    zChainMap.popitemc             G   s>   y| j d j|f|žŽ S  tk
r8   td |¡ƒ‚Y nX dS )zWRemove *key* from maps[0] and return its value. Raise KeyError if *key* not in maps[0].r   z(Key not found in the first mapping: {!r}N)rÜ   ÚpoprÝ   r·   )r]   rV   r�   r   r   r   rô   ]  s    zChainMap.popc             C   s   | j d  ¡  dS )z'Clear maps[0], leaving maps[1:] intact.r   N)rÜ   Úclear)r]   r   r   r   rõ   d  s    zChainMap.clear)N)r4   r5   r6   r`   r_   rÞ   rà   rP   râ   rä   ræ   rç   rÚ   rè   Úclassmethodrê   rî   Ú__copy__rï   Úpropertyrð   rñ   rò   ró   rô   rõ   r   r   r   r   rË     s(   
rË   )Úcache_from_sourcec             C   s0   |   d¡st‚|d krd}|r$d}nd}| | S )Nz.pyTÚcÚo)rn   ÚAssertionError)rc   Údebug_overrideÚsuffixr   r   r   rù   n  s    rù   )ÚOrderedDict)rÐ   )ÚKeysViewÚ
ValuesViewÚ	ItemsViewc               @   sþ   e Zd ZdZdd„ Zejfdd„Zejfdd„Zdd	„ Zd
d„ Z	dd„ Z
d6dd„Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ ZeZeƒ Zefdd „Zd7d"d#„Zd8d$d%„Zd&d'„ Zd(d)„ Zed9d*d+„ƒZd,d-„ Zd.d/„ Zd0d1„ Zd2d3„ Z d4d5„ Z!d!S ):rÿ   z)Dictionary that remembers insertion orderc             O   sn   t |ƒdkrtdt |ƒ ƒ‚y
| j W n6 tk
r\   g  | _}||dg|dd…< i | _Y nX | j||Ž dS )zÑInitialize an ordered dictionary.  Signature is the same as for
            regular dictionaries, but keyword arguments are not recommended
            because their insertion order is arbitrary.

            r   z$expected at most 1 arguments, got %dN)rQ   r£   Ú_OrderedDict__rootrÅ   Ú_OrderedDict__mapÚ_OrderedDict__update)r]   r�   ÚkwdsÚrootr   r   r   r_   •  s    

zOrderedDict.__init__c             C   sF   || kr6| j }|d }|||g |d<  |d< | j|< || ||ƒ dS )z!od.__setitem__(i, y) <==> od[i]=yr   r   N)r  r  )r]   rV   rW   Zdict_setitemr  Úlastr   r   r   rñ   ¥  s
     zOrderedDict.__setitem__c             C   s0   || |ƒ | j  |¡\}}}||d< ||d< dS )z od.__delitem__(y) <==> del od[y]r   r   N)r  rô   )r]   rV   Zdict_delitemÚ	link_prevÚ	link_nextr   r   r   rò   ¯  s    
zOrderedDict.__delitem__c             c   s2   | j }|d }x||k	r,|d V  |d }qW dS )zod.__iter__() <==> iter(od)r   r(   N)r  )r]   r  Úcurrr   r   r   rä   ¸  s
    

zOrderedDict.__iter__c             c   s2   | j }|d }x||k	r,|d V  |d }qW dS )z#od.__reversed__() <==> reversed(od)r   r(   N)r  )r]   r  r  r   r   r   Ú__reversed__À  s
    

zOrderedDict.__reversed__c             C   sh   yDx| j  ¡ D ]}|dd…= qW | j}||dg|dd…< | j  ¡  W n tk
rX   Y nX t | ¡ dS )z.od.clear() -> None.  Remove all items from od.N)r  Ú
itervaluesr  rõ   rÅ   ré   )r]   Únoder  r   r   r   rõ   È  s    zOrderedDict.clearTc             C   s|   | st dƒ‚| j}|r8|d }|d }||d< ||d< n |d }|d }||d< ||d< |d }| j|= t | |¡}||fS )z¡od.popitem() -> (k, v), return and remove a (key, value) pair.
            Pairs are returned in LIFO order if last is true or FIFO order if false.

            zdictionary is emptyr   r   r(   )rÝ   r  r  ré   rô   )r]   r  r  Úlinkr	  r
  rV   rW   r   r   r   ró   Ô  s     
zOrderedDict.popitemc             C   s   t | ƒS )zod.keys() -> list of keys in od)rÛ   )r]   r   r   r   Úkeysí  s    zOrderedDict.keysc                s   ‡ fdd„ˆ D ƒS )z#od.values() -> list of values in odc                s   g | ]}ˆ | ‘qS r   r   )ro   rV   )r]   r   r   rs   ó  s    z&OrderedDict.values.<locals>.<listcomp>r   )r]   r   )r]   r   Úvaluesñ  s    zOrderedDict.valuesc                s   ‡ fdd„ˆ D ƒS )z.od.items() -> list of (key, value) pairs in odc                s   g | ]}|ˆ | f‘qS r   r   )ro   rV   )r]   r   r   rs   ÷  s    z%OrderedDict.items.<locals>.<listcomp>r   )r]   r   )r]   r   Úitemsõ  s    zOrderedDict.itemsc             C   s   t | ƒS )z0od.iterkeys() -> an iterator over the keys in od)rã   )r]   r   r   r   Úiterkeysù  s    zOrderedDict.iterkeysc             c   s   x| D ]}| | V  qW dS )z2od.itervalues -> an iterator over the values in odNr   )r]   Úkr   r   r   r  ý  s    
zOrderedDict.itervaluesc             c   s    x| D ]}|| | fV  qW dS )z=od.iteritems -> an iterator over the (key, value) items in odNr   )r]   r  r   r   r   Ú	iteritems  s    
zOrderedDict.iteritemsc              O   sØ   t | ƒdkr tdt | ƒf ƒ‚n| s,tdƒ‚| d }d}t | ƒdkrL| d }t|tƒrrx^|D ]}|| ||< q\W nDt|dƒrœx8| ¡ D ]}|| ||< q†W nx|D ]\}}|||< q¢W x| ¡ D ]\}}|||< qÀW dS )	a—  od.update(E, **F) -> None.  Update od from dict/iterable E and F.

            If E is a dict instance, does:           for k in E: od[k] = E[k]
            If E has a .keys() method, does:         for k in E.keys(): od[k] = E[k]
            Or if E is an iterable of items, does:   for k, v in E: od[k] = v
            In either case, this is followed by:     for k, v in F.items(): od[k] = v

            r(   z8update() takes at most 2 positional arguments (%d given)z,update() takes at least 1 argument (0 given)r   r   r   r  N)rQ   r£   r   ré   Úhasattrr  r  )r�   r  r]   ÚotherrV   rW   r   r   r   r\     s&    	


zOrderedDict.updatec             C   s0   || kr| | }| |= |S || j kr,t|ƒ‚|S )z±od.pop(k[,d]) -> v, remove specified key and return the corresponding value.
            If key is not found, d is returned if given, otherwise KeyError is raised.

            )Ú_OrderedDict__markerrÝ   )r]   rV   rÆ   rÒ   r   r   r   rô   *  s    
zOrderedDict.popNc             C   s   || kr| | S || |< |S )zDod.setdefault(k[,d]) -> od.get(k,d), also set od[k]=d if k not in odr   )r]   rV   rÆ   r   r   r   Ú
setdefault7  s    zOrderedDict.setdefaultc             C   s^   |si }t | ƒtƒ f}||kr"dS d||< z&| s>d| jjf S d| jj|  ¡ f S ||= X dS )zod.__repr__() <==> repr(od)z...r   z%s()z%s(%r)N)rÏ   Ú
_get_identrí   r4   r  )r]   Z_repr_runningZcall_keyr   r   r   rè   >  s     zOrderedDict.__repr__c                s\   ‡ fdd„ˆ D ƒ}t ˆ ƒ ¡ }xt tƒ ƒD ]}| |d¡ q*W |rPˆ j|f|fS ˆ j|ffS )z%Return state information for picklingc                s   g | ]}|ˆ | g‘qS r   r   )ro   r  )r]   r   r   rs   N  s    z*OrderedDict.__reduce__.<locals>.<listcomp>N)Úvarsrî   rÿ   rô   rí   )r]   r  Ú	inst_dictr  r   )r]   r   Ú
__reduce__L  s    zOrderedDict.__reduce__c             C   s
   |   | ¡S )z!od.copy() -> a shallow copy of od)rí   )r]   r   r   r   rî   V  s    zOrderedDict.copyc             C   s    | ƒ }x|D ]}|||< qW |S )zˆOD.fromkeys(S[, v]) -> New ordered dictionary with keys from S
            and values equal to v (which defaults to None).

            r   )rë   rì   rW   ÚdrV   r   r   r   rê   Z  s    
zOrderedDict.fromkeysc             C   s6   t |tƒr*t| ƒt|ƒko(|  ¡ | ¡ kS t | |¡S )z›od.__eq__(y) <==> od==y.  Comparison to another OD is order-sensitive
            while comparison to a regular mapping is order-insensitive.

            )r   rÿ   rQ   r  ré   Ú__eq__)r]   r  r   r   r   r  e  s    
 zOrderedDict.__eq__c             C   s
   | |k S )Nr   )r]   r  r   r   r   Ú__ne__n  s    zOrderedDict.__ne__c             C   s   t | ƒS )z@od.viewkeys() -> a set-like object providing a view on od's keys)r   )r]   r   r   r   Úviewkeyss  s    zOrderedDict.viewkeysc             C   s   t | ƒS )z<od.viewvalues() -> an object providing a view on od's values)r  )r]   r   r   r   Ú
viewvaluesw  s    zOrderedDict.viewvaluesc             C   s   t | ƒS )zBod.viewitems() -> a set-like object providing a view on od's items)r  )r]   r   r   r   Ú	viewitems{  s    zOrderedDict.viewitems)T)N)N)N)"r4   r5   r6   r`   r_   ré   rñ   rò   rä   r  rõ   ró   r  r  r  r  r  r  r\   r  Úobjectr  rô   r  rè   r  rî   rö   rê   r  r   r!  r"  r#  r   r   r   r   rÿ   ‰  s:   
	




	rÿ   )ÚBaseConfiguratorÚvalid_identz^[a-z_][a-z0-9_]*$c             C   s   t  | ¡}|std|  ƒ‚dS )Nz!Not a valid Python identifier: %rT)Ú
IDENTIFIERr,   rO   )r   rå   r   r   r   r&  …  s    
r&  c               @   s"   e Zd ZdZdd„ Zddd„ZdS )ÚConvertingDictz A converting dictionary wrapper.c             C   sJ   t  | |¡}| j |¡}||k	rF|| |< t|ƒtttfkrF| |_||_	|S )N)
ré   rà   ÚconfiguratorÚconvertr¤   r(  ÚConvertingListÚConvertingTupleÚparentrV   )r]   rV   rW   rÒ   r   r   r   rà   ˜  s    
zConvertingDict.__getitem__Nc             C   sL   t  | ||¡}| j |¡}||k	rH|| |< t|ƒtttfkrH| |_||_	|S )N)
ré   rP   r)  r*  r¤   r(  r+  r,  r-  rV   )r]   rV   rÆ   rW   rÒ   r   r   r   rP   ¤  s    
zConvertingDict.get)N)r4   r5   r6   r`   rà   rP   r   r   r   r   r(  •  s   r(  c             C   sD   t  | ||¡}| j |¡}||k	r@t|ƒtttfkr@| |_||_	|S )N)
ré   rô   r)  r*  r¤   r(  r+  r,  r-  rV   )r]   rV   rÆ   rW   rÒ   r   r   r   rô   °  s    
rô   c               @   s"   e Zd ZdZdd„ Zddd„ZdS )	r+  zA converting list wrapper.c             C   sJ   t  | |¡}| j |¡}||k	rF|| |< t|ƒtttfkrF| |_||_	|S )N)
rÛ   rà   r)  r*  r¤   r(  r+  r,  r-  rV   )r]   rV   rW   rÒ   r   r   r   rà   ¼  s    
zConvertingList.__getitem__éÿÿÿÿc             C   s<   t  | |¡}| j |¡}||k	r8t|ƒtttfkr8| |_|S )N)	rÛ   rô   r)  r*  r¤   r(  r+  r,  r-  )r]   ÚidxrW   rÒ   r   r   r   rô   È  s    
zConvertingList.popN)r.  )r4   r5   r6   r`   rà   rô   r   r   r   r   r+  º  s   r+  c               @   s   e Zd ZdZdd„ ZdS )r,  zA converting tuple wrapper.c             C   sB   t  | |¡}| j |¡}||k	r>t|ƒtttfkr>| |_||_	|S )N)
Útuplerà   r)  r*  r¤   r(  r+  r,  r-  rV   )r]   rV   rW   rÒ   r   r   r   rà   Ó  s    
zConvertingTuple.__getitem__N)r4   r5   r6   r`   rà   r   r   r   r   r,  Ñ  s   r,  c               @   sŒ   e Zd ZdZe d¡Ze d¡Ze d¡Ze d¡Z	e d¡Z
ddd	œZeeƒZd
d„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ ZdS )r%  zQ
        The configurator base class which defines some useful defaults.
        z%^(?P<prefix>[a-z]+)://(?P<suffix>.*)$z^\s*(\w+)\s*z^\.\s*(\w+)\s*z^\[\s*(\w+)\s*\]\s*z^\d+$Úext_convertÚcfg_convert)rp   Úcfgc             C   s   t |ƒ| _| | j_d S )N)r(  Úconfigr)  )r]   r4  r   r   r   r_   ñ  s    
zBaseConfigurator.__init__c       	   	   C   sÄ   |  d¡}| d¡}y`|  |¡}xP|D ]H}|d| 7 }yt||ƒ}W q& tk
rl   |  |¡ t||ƒ}Y q&X q&W |S  tk
r¾   t ¡ dd… \}}td||f ƒ}|| |_	|_
|‚Y nX dS )zl
            Resolve strings to objects using standard import and attribute
            syntax.
            r7   r   r   NzCannot resolve %r: %s)r9   rô   ÚimporterrØ   rÅ   ÚImportErrorrx   rŒ   rO   Ú	__cause__Ú__traceback__)	r]   r   r†   ÚusedÚfoundrH   ÚeÚtbÚvr   r   r   Úresolveõ  s"    




zBaseConfigurator.resolvec             C   s
   |   |¡S )z*Default converter for the ext:// protocol.)r>  )r]   rW   r   r   r   r1    s    zBaseConfigurator.ext_convertc             C   s  |}| j  |¡}|dkr&td| ƒ‚nØ|| ¡ d… }| j| ¡ d  }x´|rü| j |¡}|rp|| ¡ d  }nd| j |¡}|rÔ| ¡ d }| j |¡s¢|| }n2yt	|ƒ}|| }W n t
k
rÒ   || }Y nX |rê|| ¡ d… }qJtd||f ƒ‚qJW |S )z*Default converter for the cfg:// protocol.NzUnable to convert %rr   zUnable to convert %r at %r)ÚWORD_PATTERNr,   rO   Úendr4  ÚgroupsÚDOT_PATTERNÚINDEX_PATTERNÚDIGIT_PATTERNÚintr£   )r]   rW   Úrestrå   r  r/  Únr   r   r   r2    s2    
zBaseConfigurator.cfg_convertc             C   sÆ   t |tƒs$t |tƒr$t|ƒ}| |_nžt |tƒsHt |tƒrHt|ƒ}| |_nzt |tƒslt |tƒrlt|ƒ}| |_nVt |tƒrÂ| j	 
|¡}|rÂ| ¡ }|d }| j |d¡}|rÂ|d }t| |ƒ}||ƒ}|S )zù
            Convert values to an appropriate type. dicts, lists and tuples are
            replaced by their converting alternatives. Strings are checked to
            see if they have a conversion format and are converted if they do.
            ÚprefixNrþ   )r   r(  ré   r)  r+  rÛ   r,  r0  Ústring_typesÚCONVERT_PATTERNr,   Ú	groupdictÚvalue_convertersrP   rØ   )r]   rW   rå   r  rH  Ú	converterrþ   r   r   r   r*  2  s*    



zBaseConfigurator.convertc                sr   ˆ   d¡}t|ƒs|  |¡}ˆ   dd¡}t‡ fdd„ˆ D ƒƒ}|f |Ž}|rnx | ¡ D ]\}}t|||ƒ qVW |S )z1Configure an object with a user-supplied factory.z()r7   Nc                s    g | ]}t |ƒr|ˆ | f‘qS r   )r&  )ro   r  )r4  r   r   rs   U  s    z5BaseConfigurator.configure_custom.<locals>.<listcomp>)rô   r›   r>  ré   r  Úsetattr)r]   r4  rú   Úpropsr^   rÒ   r†   rW   r   )r4  r   Úconfigure_customN  s    


z!BaseConfigurator.configure_customc             C   s   t |tƒrt|ƒ}|S )z0Utility function which converts lists to tuples.)r   rÛ   r0  )r]   rW   r   r   r   Úas_tuple\  s    
zBaseConfigurator.as_tupleN)r4   r5   r6   r`   r*   r+   rJ  r?  rB  rC  rD  rL  ÚstaticmethodÚ
__import__r5  r_   r>  r1  r2  r*  rP  rQ  r   r   r   r   r%  Ý  s    




"r%  )r   )rÎ   )N)N)‘Ú
__future__r   rb   r*   rx   Ússlr6  Úversion_infor   Ú
basestringrI  r   r    Útypesr   Ú	file_typeÚ__builtin__ÚbuiltinsÚConfigParserÚconfigparserZ	_backportr   r   r	   r
   r   r   Úurllibr   r   r   r   r   r   r   r   Úurllib2r   r   r   r   r   r    r!   r"   r#   r$   ÚhttplibÚ	xmlrpclibÚQueueÚqueuer%   ÚhtmlentitydefsÚ	raw_inputÚ	itertoolsr&   Úfilterr'   r1   r)   r/   ÚioÚstrr0   Úurllib.parseÚurllib.requestÚurllib.errorÚhttp.clientÚclientÚrequestÚxmlrpc.clientÚhtml.parserÚhtml.entitiesÚentitiesÚinputr2   r3   rO   rJ   rY   rZ   r$  ra   ÚF_OKÚX_OKÚzipfiler‡   rŽ   r  r‰   ZBaseZipExtFilery   r‘   r˜   r›   Ú	NameErrorÚcollectionsr™   r¦   r¨   rÅ   Úgetfilesystemencodingr¡   r¢   Útokenizer©   Úcodecsrª   r«   r+   r¹   r±   Úhtmlr?   ÚcgirÊ   rË   rÌ   ÚreprlibrÍ   rÚ   Úimportlib.utilrù   Úimprÿ   ÚthreadrÐ   r  Údummy_threadÚ_abcollr   r  r  ré   Úlogging.configr%  r&  ÚIr'  r(  rô   rÛ   r+  r0  r,  r   r   r   r   Ú<module>   s,  
$,,0
2+A


		
[
b
 w

