o
    Tpf                     @   s  d dl mZ d dlZd dlZd dlZzd dlZW n ey#   dZY nw ejd  dk rd 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rd dl$m.Z. d dl/Z/d dl0Z0d dl1Z2d dl3m3Z3 d dl4Z4e5Z5d dl6m7Z8 d dl6m9Z: nd 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# d dl?m&Z&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@m(Z(m'Z'm"Z" d dlAmBZ/ d dl?mCZ$ d dlDmBZ0 d dl2Z2d dlEm3Z3 d dlFmGZ4 eHZ5d dl6m:Z: e8Z8z
d dlmIZImJZJ W n eyb   G dd deKZJdbddZLdd ZIY nw zd dlmMZN W n ey}   G dd deOZNY nw zd d lmPZP W n ey   ejQejRB dfd!d"ZPY nw d d#lSmTZU eVeUd$reUZTnd d%lSmWZX G d&d' d'eXZWG d(d) d)eUZTzd d*lYmZZZ W n ey   d+d, ZZY nw zd dl[Z[W n ey   dd-lm[Z[ Y nw ze\Z\W n e]y   d d.l^m_Z_ d/d0 Z\Y nw zej`Z`ejaZaW n# eby3   ec pd1Zdedd2kr'd3Zend4Zed5d6 Z`d7d8 ZaY nw zd d9lfmgZg W n# ey_   d d:lhmiZimjZj d dlZekd;Zld<d= Zmd>d? ZgY nw zd d@lnmoZo W n eyx   d d@lpmoZo Y nw ejddA dBk re3 jqZqnd dClnmqZq zd dDlrmsZs W n0 ey   d dElrmtZt zd dFlumvZw W n ey   dcdHdIZwY nw G dJdK dKetZsY nw zd dLlxmyZy W n" ey   zd dLlzmyZy W n ey   dddMdNZyY nw Y nw zd dOlrm{Z{ W nB ey<   zd dPl|m}Z~ W n ey   d dPlm}Z~ Y nw zd dQlmZmZmZ W n
 ey1   Y nw G dRdS dSeZ{Y nw zd dTlmZmZ W dS  ey   ekdUejZdVdW ZG dXdY dYeZdddZd[ZG d\d] d]eZG d^d_ d_eZG d`da daeOZY dS w )e    )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 )Nutf-8)
isinstanceunicodeencode_quote)s r   RD:\crud-operations\pythonnew\myenv\Lib\site-packages\pip/_vendor/distlib/compat.pyr      s   

r   )	RequesturlopenURLError	HTTPErrorHTTPBasicAuthHandlerHTTPPasswordMgrHTTPHandlerHTTPRedirectHandlerbuild_opener)HTTPSHandler)
HTMLParser)ifilter)ifilterfalse)TextIOWrapper)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 )r,   N)__name__
__module____qualname__r   r   r   r   r,   `   s    r,   c           
      C   s   g }| sdS |  d}|d |dd }}|d}||kr'tdt|  |s1|  | kS |dkr;|d n|d	sE|d	rN|t| n|t|	d
d |D ]
}|t| q\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countr,   reprlowerappend
startswithreescapereplacecompilejoin
IGNORECASEmatch)
dnhostnamemax_wildcardspatspartsleftmost	remainder	wildcardsfragpatr   r   r   _dnsname_matchd   s*   



rI   c                 C   s   | st dg }| dd}|D ]\}}|dkr%t||r  dS || q|sJ| ddD ]}|D ]\}}|dkrHt||rC  dS || q2q.t|dkr^td	|d
tt|f t|dkrntd||d f td)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 %s, zhostname %r doesn't match %rr   z=no appropriate commonName or subjectAltName fields were found)	
ValueErrorgetrI   r6   lenr,   r<   mapr4   )certr@   dnsnamessankeyvaluesubr   r   r   r+      s8   




r+   )SimpleNamespacec                   @      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)r-   r.   r/   __doc__rb   r   r   r   r   r[      s    r[   )whichc                    s"  dd }t j r| |r S dS |du rt jdt j}|s#dS |t j}tj	dkr^t j
|vr:|dt j
 t jddt j}t fd	d
|D rT g}n fdd|D }n g}t }|D ](}t j|}||vr|| |D ]}	t j||	}
||
|r|
    S qyqfd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 r\   )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 r\   )r5   endswith.0extcmdr   r   	<genexpr>   s     zwhich.<locals>.<genexpr>c                    s   g | ]} | qS r   r   rr   ru   r   r   
<listcomp>       zwhich.<locals>.<listcomp>)re   rf   dirnameenvironrP   defpathr2   pathsepsysplatformcurdirinsertanysetnormcaseaddr<   )rv   rk   rf   rl   pathextfilesseendirnormdirthefilenamer   ru   r   rd      s<   




rd   )ZipFile	__enter__)
ZipExtFilec                   @   $   e Zd Zdd Zdd Zdd ZdS )r   c                 C   s   | j |j  d S r\   r]   )r`   baser   r   r   rb        zZipExtFile.__init__c                 C      | S r\   r   r`   r   r   r   r        zZipExtFile.__enter__c                 G      |    d S r\   closer`   exc_infor   r   r   __exit__     zZipExtFile.__exit__N)r-   r.   r/   rb   r   r   r   r   r   r   r     s    r   c                   @   r   )r   c                 C   r   r\   r   r   r   r   r   r   $  r   zZipFile.__enter__c                 G   r   r\   r   r   r   r   r   r   '  r   zZipFile.__exit__c                 O   s    t j| g|R i |}t|S r\   )BaseZipFileopenr   )r`   argsra   r   r   r   r   r   +  s   zZipFile.openN)r-   r.   r/   r   r   r   r   r   r   r   r   #  s    r   )python_implementationc                   C   s0   dt jv 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)r~   versionre   r   r7   r   r   r   r   r   2  s   

r   )	sysconfig)Callablec                 C   s
   t | tS r\   )r   r   )objr   r   r   callableF     
r   r   mbcsstrictsurrogateescapec                 C   6   t | tr| S t | tr| ttS tdt| j Nzexpect bytes or str, not %s)	r   bytes	text_typer   _fsencoding	_fserrors	TypeErrortyper-   filenamer   r   r   fsencodeZ     

r   c                 C   r   r   )	r   r   r   decoder   r   r   r   r-   r   r   r   r   fsdecodec  r   r   )detect_encoding)BOM_UTF8lookupzcoding[:=]\s*([-\w.]+)c                 C   sH   | dd   dd}|dks|drdS |dv s |dr"d	S | S )
z(Imitates get_normal_name in tokenizer.c.N   _-r   zutf-8-)zlatin-1
iso-8859-1ziso-latin-1)zlatin-1-ziso-8859-1-ziso-latin-1-r   )r5   r:   r7   )orig_encencr   r   r   _get_normal_namet  s   r   c                    s   zj jW n ty   dY nw d d}d}fdd} fdd}| }|tr7d |d	d }d
}|s=|g fS ||}|rH||gfS | }|sR||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.
        NFr   c                      s   z  W S  t y   Y dS w )N    )StopIterationr   )readliner   r   read_or_stop  s
   z%detect_encoding.<locals>.read_or_stopc                    s   z|  d}W n ty   d}d urd|}t|w t|}|s(d S t|d }zt|}W n tyQ   d u rGd| }t|d|}t|w  rp|j	dkrld u rcd}t|d}t||d	7 }|S )
Nr   z'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  s@   
	

z$detect_encoding.<locals>.find_cookieTr   z	utf-8-sig)__self__r   AttributeErrorr7   r   )r   r   defaultr   r   firstsecondr   )r   r   r   r   r     s6   &


r   )r9      )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              	      sJ   t | t f}|v r S | z| }W | |S | w r\   )id	get_identr   discard)r`   rV   result)	fillvaluerepr_runninguser_functionr   r   wrapper  s   


z=_recursive_repr.<locals>.decorating_function.<locals>.wrapperr.   rc   r-   __annotations__)r   getattrr.   rc   r-   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 )zInitialize 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   rb     s   zChainMap.__init__c                 C   s   t |r\   )KeyErrorr`   rV   r   r   r   __missing__  s   zChainMap.__missing__c              	   C   s6   | j D ]}z|| W   S  ty   Y qw | |S r\   )r   r   r   )r`   rV   mappingr   r   r   __getitem__  s   

zChainMap.__getitem__Nc                 C   s   || v r| | S |S r\   r   r`   rV   r   r   r   r   rP   '  s   zChainMap.getc                 C      t t j| j S r\   )rQ   r   unionr   r   r   r   r   __len__*  r   zChainMap.__len__c                 C   r   r\   )iterr   r   r   r   r   r   r   __iter__-  r   zChainMap.__iter__c                    s   t  fdd| jD S )Nc                 3   s    | ]} |v V  qd S r\   r   )rs   mrV   r   r   rw   1  s    z(ChainMap.__contains__.<locals>.<genexpr>r   r   r   r   r   r   __contains__0  s   zChainMap.__contains__c                 C   s
   t | jS r\   r  r   r   r   r   __bool__3  r   zChainMap.__bool__c                 C   s   d | dtt| jS )Nz{0.__class__.__name__}({1})rN   )r   r<   rR   r4   r   r   r   r   r   __repr__6  s   zChainMap.__repr__c                 G   s   | t j|g|R  S )z?Create a ChainMap with a single dict created from the iterable.)dictfromkeys)clsiterabler   r   r   r   r  ;  s   zChainMap.fromkeysc                 C   s&   | j | jd  g| jdd R  S )zHNew ChainMap or subclass with a new copy of maps[0] and refs to maps[1:]r   r   N)	__class__r   copyr   r   r   r   r
  @  s   &zChainMap.copyc                 C   s   | j i g| jR  S )z;New ChainMap with a new dict followed by all previous maps.r	  r   r   r   r   r   	new_childF  s   zChainMap.new_childc                 C   s   | j | jdd  S )zNew ChainMap from maps[1:].r   Nr  r   r   r   r   parentsJ  s   zChainMap.parentsc                 C   s   || j d |< d S )Nr   )r   )r`   rV   rW   r   r   r   __setitem__O  r   zChainMap.__setitem__c                 C   s0   z	| j d |= W d S  ty   td|w )Nr   (Key not found in the first mapping: {!r})r   r   r   r   r   r   r   __delitem__R  s
   zChainMap.__delitem__c                 C   s(   z| j d  W S  ty   tdw )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.)r   popitemr   r   r   r   r   r  X  s
   zChainMap.popitemc                 G   s8   z| j d j|g|R  W S  ty   td|w )zWRemove *key* from maps[0] and return its value. Raise KeyError if *key* not in maps[0].r   r  )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   clearr   r   r   r   r  f     zChainMap.clearr\   )r-   r.   r/   rc   rb   r   r   rP   r   r   r  r  r   r  classmethodr  r
  __copy__r  propertyr  r  r  r  r  r  r   r   r   r   r     s0    



r   )cache_from_sourcec                 C   s6   |  dsJ |d u rd}|rd}| | S d}| | S )Nz.pyTco)rq   )rf   debug_overridesuffixr   r   r   r  p  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d7d$d%Zd&d' Zd(d) Zed7d*d+Zd,d- Zd.d/ Zd0d1 Zd2d3 Z d4d5 Z!d!S )8r  z)Dictionary that remembers insertion orderc                 O   sp   t |dkrtdt | z| j W n ty-   g  | _}||dg|dd< i | _Y nw | j|i | dS )zInitialize 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   rb     s   


zOrderedDict.__init__c                 C   sF   || vr| 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   :    | j }|d }||ur|d V  |d }||usdS dS )zod.__iter__() <==> iter(od)r   r   Nr!  r`   r%  currr   r   r   r        
zOrderedDict.__iter__c                 c   r)  )z#od.__reversed__() <==> reversed(od)r   r   Nr*  r+  r   r   r   __reversed__  r-  zOrderedDict.__reversed__c                 C   sb   z | j  D ]}|dd= q| j}||dg|dd< | j   W n	 ty)   Y nw 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}|r|d }|d }||d< ||d< n|d }|d }||d< ||d< |d }| j|= t| |}||fS )zod.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      t | S )zod.keys() -> list of keys in od)r   r   r   r   r   keys     zOrderedDict.keysc                        fdd D S )z#od.values() -> list of values in odc                    s   g | ]} | qS r   r   rs   rV   r   r   r   rx     ry   z&OrderedDict.values.<locals>.<listcomp>r   r   r   r   r   values  r  zOrderedDict.valuesc                    r5  )z.od.items() -> list of (key, value) pairs in odc                    s   g | ]}| | fqS r   r   r6  r   r   r   rx         z%OrderedDict.items.<locals>.<listcomp>r   r   r   r   r   items  r  zOrderedDict.itemsc                 C   r2  )z0od.iterkeys() -> an iterator over the keys in od)r   r   r   r   r   iterkeys  r4  zOrderedDict.iterkeysc                 c   s    | D ]}| | V  qdS )z2od.itervalues -> an iterator over the values in odNr   r`   kr   r   r   r/    s   zOrderedDict.itervaluesc                 c   s    | D ]	}|| | fV  qdS )z=od.iteritems -> an iterator over the (key, value) items in odNr   r;  r   r   r   	iteritems  s   zOrderedDict.iteritemsc                  O   s   t | dkrtdt | f | std| d }d}t | dkr%| d }t|tr6|D ]}|| ||< q,nt|drI| D ]}|| ||< q?n|D ]\}}|||< qK| D ]\}}|||< qXd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   r3  N)rQ   r   r   r  hasattrr3  r9  )r   r$  r`   otherrV   rW   r   r   r   r_   	  s.   	



zOrderedDict.updatec                 C   s0   || v r| | }| |= |S || j u rt||S )zod.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   || v r| | S || |< |S )zDod.setdefault(k[,d]) -> od.get(k,d), also set od[k]=d if k not in odr   r   r   r   r   
setdefault9  s   zOrderedDict.setdefaultc                 C   sj   |si }t | t f}||v rdS d||< z| s#d| jjf W ||= S d| jj|  f W ||= S ||= w )zod.__repr__() <==> repr(od)r   r   z%s()z%s(%r))r   
_get_identr	  r-   r9  )r`   _repr_runningZcall_keyr   r   r   r  @  s   zOrderedDict.__repr__c                    sX    fdd D }t   }t t D ]}||d q|r& j|f|fS  j|ffS )z%Return state information for picklingc                    s   g | ]}| | gqS r   r   rs   r<  r   r   r   rx   P  r8  z*OrderedDict.__reduce__.<locals>.<listcomp>N)varsr
  r  r  r	  )r`   r9  	inst_dictr<  r   r   r   
__reduce__N  s   zOrderedDict.__reduce__c                 C   s
   |  | S )z!od.copy() -> a shallow copy of od)r	  r   r   r   r   r
  X     
zOrderedDict.copyc                 C   s   |  }|D ]}|||< q|S )zOD.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  \  s   
zOrderedDict.fromkeysc                 C   s6   t |trt| t|ko|  | kS t| |S )zod.__eq__(y) <==> od==y.  Comparison to another OD is order-sensitive
            while comparison to a regular mapping is order-insensitive.

            )r   r  rQ   r9  r  __eq__r`   r?  r   r   r   rJ  g  s   
 zOrderedDict.__eq__c                 C   s
   | |k S r\   r   rK  r   r   r   __ne__p  r   zOrderedDict.__ne__c                 C   r2  )z@od.viewkeys() -> a set-like object providing a view on od's keys)r  r   r   r   r   viewkeysu  r4  zOrderedDict.viewkeysc                 C   r2  )z<od.viewvalues() -> an object providing a view on od's values)r  r   r   r   r   
viewvaluesy  r4  zOrderedDict.viewvaluesc                 C   r2  )zBod.viewitems() -> a set-like object providing a view on od's items)r   r   r   r   r   	viewitems}  r4  zOrderedDict.viewitems)Tr\   )"r-   r.   r/   rc   rb   r  r  r  r   r.  r  r  r3  r7  r9  r:  r/  r=  r_   r#  objectr@  r  rA  r  rG  r
  r  r  rJ  rL  rM  rN  rO  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   rR    s   
rR  c                   @   s"   e Zd ZdZdd ZdddZdS )ConvertingDictz A converting dictionary wrapper.c                 C   J   t | |}| j|}||ur#|| |< t|tttfv r#| |_||_	|S r\   )
r  r   configuratorconvertr   rT  ConvertingListConvertingTupleparentrV   r`   rV   rW   r   r   r   r   r        
zConvertingDict.__getitem__Nc                 C   sL   t | ||}| j|}||ur$|| |< t|tttfv r$| |_||_	|S r\   )
r  rP   rV  rW  r   rT  rX  rY  rZ  rV   r`   rV   r   rW   r   r   r   r   rP     s   
zConvertingDict.getr\   )r-   r.   r/   rc   r   rP   r   r   r   r   rT    s    rT  c                 C   sD   t | ||}| j|}||ur t|tttfv r | |_||_	|S r\   )
r  r  rV  rW  r   rT  rX  rY  rZ  rV   r]  r   r   r   r    s   
r  c                   @   s"   e Zd ZdZdd ZdddZdS )	rX  zA converting list wrapper.c                 C   rU  r\   )
r   r   rV  rW  r   rT  rX  rY  rZ  rV   r[  r   r   r   r     r\  zConvertingList.__getitem__c                 C   s<   t | |}| j|}||urt|tttfv r| |_|S r\   )	r   r  rV  rW  r   rT  rX  rY  rZ  )r`   idxrW   r   r   r   r   r    s   
zConvertingList.popN)r^  )r-   r.   r/   rc   r   r  r   r   r   r   rX    s    rX  c                   @   rZ   )rY  zA converting tuple wrapper.c                 C   sB   t | |}| j|}||urt|tttfv r| |_||_	|S r\   )
tupler   rV  rW  r   rT  rX  rY  rZ  rV   r[  r   r   r   r     s   
zConvertingTuple.__getitem__N)r-   r.   r/   rc   r   r   r   r   r   rY    s    rY  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 )rQ  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)rt   cfgc                 C   s   t || _| | j_d S r\   )rT  configrV  )r`   rd  r   r   r   rb     s   
zBaseConfigurator.__init__c           	   	   C   s   | d}|d}z-| |}|D ]"}|d| 7 }zt||}W q ty4   | | t||}Y qw |W S  tyY   t dd \}}td||f }|||_	|_
|w )zl
            Resolve strings to objects using standard import and attribute
            syntax.
            r0   r   r   NzCannot resolve %r: %s)r2   r  importerr   r   ImportErrorr~   r   rO   	__cause____traceback__)	r`   r   r   usedfoundrG   etbvr   r   r   resolve  s&   



zBaseConfigurator.resolvec                 C   s
   |  |S )z*Default converter for the ext:// protocol.)rn  r`   rW   r   r   r   ra    rH  zBaseConfigurator.ext_convertc                 C   s   |}| j |}|du rtd| || d }| j| d  }|r|| j|}|r6|| d  }n1| j|}|rg| d }| j|sO|| }nz
t	|}|| }W n t
yf   || }Y nw |rr|| d }ntd||f |s%|S )z*Default converter for the cfg:// protocol.NzUnable to convert %rr   zUnable to convert %r at %r)WORD_PATTERNr>   rO   endrd  groupsDOT_PATTERNINDEX_PATTERNDIGIT_PATTERNintr   )r`   rW   restr   rI  r_  nr   r   r   rb    s8   
zBaseConfigurator.cfg_convertc                 C   s   t |tst |trt|}| |_|S t |ts&t |tr&t|}| |_|S t |ts9t |tr9t|}| |_|S t |trd| j	
|}|rd| }|d }| j|d}|rd|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   rT  r  rV  rX  r   rY  r`  string_typesCONVERT_PATTERNr>   	groupdictvalue_convertersrP   r   )r`   rW   r   rI  ry  	converterr  r   r   r   rW  4  s2   


zBaseConfigurator.convertc                    sr     d}t|s| |}  dd}t fdd D }|di |}|r7| D ]
\}}t||| q,|S )z1Configure an object with a user-supplied factory.z()r0   Nc                    s    g | ]}t |r| | fqS r   )rR  rD  rd  r   r   rx   W  s     z5BaseConfigurator.configure_custom.<locals>.<listcomp>r   )r  r   rn  r  r9  setattr)r`   rd  r  propsra   r   r   rW   r   r  r   configure_customP  s   

z!BaseConfigurator.configure_customc                 C   s   t |tr	t|}|S )z0Utility function which converts lists to tuples.)r   r   r`  ro  r   r   r   as_tuple^  s   
zBaseConfigurator.as_tupleN)r-   r.   r/   rc   r8   r;   r{  rp  rs  rt  ru  r}  staticmethod
__import__re  rb   rn  ra  rb  rW  r  r  r   r   r   r   rQ    s$    




"rQ  )r   )r   r\   )
__future__r   re   r8   r~   sslrf  version_infor   
basestringrz  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(   r*   iostrr)   urllib.parseurllib.requesturllib.errorhttp.clientclientrequestxmlrpc.clienthtml.parserhtml.entitiesentitiesinputr+   r,   rO   rI   rY   r[   rP  rd   F_OKX_OKzipfiler   r   r>  r   ZBaseZipExtFiler   r   r   r   	NameErrorcollections.abcr   r   r   r   getfilesystemencodingr   r   tokenizer   codecsr   r   r;   r   r   htmlr9   cgir   collectionsr   r   reprlibr   r   importlib.utilr  impr  threadr   rB  dummy_thread_abcollr  r  r   r  logging.configrQ  rR  IrS  rT  r  r   rX  r`  rY  r   r   r   r   <module>   sT  $,(0
2b	C

	
l
   

