Current File : //lib/python3.9/site-packages/pip/_vendor/distlib/__pycache__/compat.cpython-39.pyc
a

[��f��@sddlmZddlZddlZddlZzddlZWneyFdZYn0ejddk�rpddlmZe	fZ
eZddl
mZddlZddlZddlmZddlmZmZmZmZmZdd	lmZmZmZm Z m!Z!m"Z"m#Z#d
d�Zddl$Z$ddl$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-e�r$dd
l$m.Z.ddl/Z/ddl0Z0ddl1Z2ddl3m3Z3ddl4Z4e5Z5ddl6m7Z8ddl6m9Z:�nddl;mZe<fZ
e<Zddl;m=ZddlZddlZddlZddl>mZmZmZmZmZmZmZm#Z#ddl?m&Z&mZm%Z%m Z m!Z!m)Z)m*Z*m+Z+m,Z,m-Z-e�rdd
l?m.Z.ddl@m(Z(m'Z'm"Z"ddlAmBZ/ddl?mCZ$ddlDmBZ0ddl2Z2ddlEm3Z3ddlFmGZ4eHZ5ddl6m:Z:e8Z8zddlmIZImJZJWn6e�y�Gdd�deK�ZJdbdd�ZLdd�ZIYn0zddl
mMZNWn$e�yGdd�deO�ZNYn0zdd lmPZPWn*e�y<ejQejRBdfd!d"�ZPYn0dd#lSmTZUeVeUd$��r\eUZTn,dd%lSmWZXGd&d'�d'eX�ZWGd(d)�d)eU�ZTzdd*lYmZZZWne�y�d+d,�ZZYn0zddl[Z[Wn e�y�dd-lm[Z[Yn0ze\Z\Wn(e]�ydd.l^m_Z_d/d0�Z\Yn0zej`Z`ejaZaWnFeb�yle�c��pBd1Zdedd2k�rTd3Zend4Zed5d6�Z`d7d8�ZaYn0zdd9lfmgZgWnFe�y�dd:lhmiZimjZjddlZe�kd;�Zld<d=�Zmd>d?�ZgYn0zdd@lnmoZoWn e�y�dd@lpmoZoYn0ejddA�dBk�re3�jqZqnddClnmqZqzddDlrmsZsWn`e�y�ddElrmtZtzddFlumvZwWne�y|dcdHdI�ZwYn0GdJdK�dKet�ZsYn0zddLlxmyZyWnDe�y�zddLlzmyZyWne�y�dddMdN�ZyYn0Yn0zddOlrm{Z{Wn�e�y~zddPl|m}Z~Wn e�y:ddPlm}Z~Yn0zddQl�m�Z�m�Z�m�Z�Wne�yhYn0GdRdS�dSe��Z{Yn0zddTl�m�Z�m�Z�Wnte�ye�kdUej��Z�dVdW�Z�GdXdY�dYe��Z�dedZd[�Z�Gd\d]�d]e��Z�Gd^d_�d_e��Z�Gd`da�daeO�Z�Yn0dS)f�)�absolute_importN�)�StringIO)�FileType�)�shutil)�urlparse�
urlunparse�urljoin�urlsplit�
urlunsplit)�urlretrieve�quote�unquote�url2pathname�pathname2url�ContentTooShortError�	splittypecCst|t�r|�d�}t|�S)N�utf-8)�
isinstance�unicode�encode�_quote)�s�r�>/usr/lib/python3.9/site-packages/pip/_vendor/distlib/compat.pyrs

r)	�Request�urlopen�URLError�	HTTPError�HTTPBasicAuthHandler�HTTPPasswordMgr�HTTPHandler�HTTPRedirectHandler�build_opener)�HTTPSHandler)�
HTMLParser)�ifilter)�ifilterfalse)�
TextIOWrapper)rr	r
rrrrr)
rr
rrrr r!r"r#r$)rrr)�filterfalse)�match_hostname�CertificateErrorc@seZdZdS)r,N)�__name__�
__module__�__qualname__rrrrr,`sr,c
Cs�g}|sdS|�d�}|d|dd�}}|�d�}||krNtdt|���|sb|��|��kS|dkrv|�d�n>|�d	�s�|�d	�r�|�t�|��n|�t�|��	d
d��|D]}|�t�|��q�t�
dd
�|�dtj�}	|	�
|�S)zpMatching according to RFC 6125, section 6.4.3

        http://tools.ietf.org/html/rfc6125#section-6.4.3
        F�.rrN�*z,too many wildcards in certificate DNS name: z[^.]+zxn--z\*z[^.]*z\Az\.z\Z)�split�countr,�repr�lower�append�
startswith�re�escape�replace�compile�join�
IGNORECASE�match)
Zdn�hostnameZ
max_wildcardsZpats�partsZleftmostZ	remainderZ	wildcards�frag�patrrr�_dnsname_matchds*


�rCcCs�|std��g}|�dd�}|D]*\}}|dkr t||�r@dS|�|�q |s�|�dd�D]6}|D],\}}|dkrdt||�r�dS|�|�qdq\t|�dkr�td	|d
�tt|��f��n*t|�dkr�td||df��ntd
��dS)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_REQUIREDZsubjectAltNamerZDNSNZsubjectZ
commonNamerz&hostname %r doesn't match either of %s�, zhostname %r doesn't match %rrz=no appropriate commonName or subjectAltName fields were found)	�
ValueError�getrCr6�lenr,r<�mapr4)Zcertr?ZdnsnamesZsan�key�value�subrrrr+�s2

�
�r+)�SimpleNamespacec@seZdZdZdd�ZdS)�	ContainerzR
        A generic container for when multiple values need to be returned
        cKs|j�|�dS�N��__dict__�update)�self�kwargsrrr�__init__�szContainer.__init__N)r-r.r/�__doc__rTrrrrrM�srM)�whichcs"dd�}tj���r&|�|�r"�SdS|dur>tj�dtj�}|sFdS|�tj�}tj	dkr�tj
|vrt|�dtj
�tj�dd��tj�}t�fd	d
�|D��r��g}q‡fdd�|D�}n�g}t
�}|D]P}tj�|�}||vr�|�|�|D](}	tj�||	�}
||
|�r�|
Sq�q�dS)
aKGiven 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.

        cSs&tj�|�o$t�||�o$tj�|�SrN)�os�path�exists�access�isdir)�fn�moderrr�
_access_check�s�zwhich.<locals>._access_checkN�PATH�win32r�PATHEXT�c3s |]}����|���VqdSrN)r5�endswith��.0�ext��cmdrr�	<genexpr>��zwhich.<locals>.<genexpr>csg|]}�|�qSrrrdrgrr�
<listcomp>�rjzwhich.<locals>.<listcomp>)rWrX�dirname�environrF�defpathr2�pathsep�sys�platform�curdir�insert�any�set�normcase�addr<)rhr]rXr^�pathext�files�seen�dir�normdir�thefile�namerrgrrV�s8





rV)�ZipFile�	__enter__)�
ZipExtFilec@s$eZdZdd�Zdd�Zdd�ZdS)r�cCs|j�|j�dSrNrO)rR�baserrrrTszZipExtFile.__init__cCs|SrNr�rRrrrr�szZipExtFile.__enter__cGs|��dSrN��close�rR�exc_inforrr�__exit__szZipExtFile.__exit__N)r-r.r/rTr�r�rrrrr�sr�c@s$eZdZdd�Zdd�Zdd�ZdS)rcCs|SrNrr�rrrr�$szZipFile.__enter__cGs|��dSrNr�r�rrrr�'szZipFile.__exit__cOs tj|g|�Ri|��}t|�SrN)�BaseZipFile�openr�)rR�argsrSr�rrrr�+szZipFile.openN)r-r.r/r�r�r�rrrrr#sr)�python_implementationcCs0dtjvrdStjdkrdStj�d�r,dSdS)z6Return a string identifying the Python implementation.ZPyPy�javaZJythonZ
IronPythonZCPython)rp�versionrWr~r7rrrrr�2s

r�)�	sysconfig)�CallablecCs
t|t�SrN)rr�)�objrrr�callableFsr�r�mbcs�strict�surrogateescapecCs:t|t�r|St|t�r$|�tt�Stdt|�j��dS�Nzexpect bytes or str, not %s)	r�bytes�	text_typer�_fsencoding�	_fserrors�	TypeError�typer-��filenamerrr�fsencodeZs

�r�cCs:t|t�r|St|t�r$|�tt�Stdt|�j��dSr�)	rr�r��decoder�r�r�r�r-r�rrr�fsdecodecs

�r�)�detect_encoding)�BOM_UTF8�lookupzcoding[:=]\s*([-\w.]+)cCsH|dd����dd�}|dks*|�d�r.dS|dvs@|�d�rDd	S|S)
z(Imitates get_normal_name in tokenizer.c.N��_�-rzutf-8-)zlatin-1�
iso-8859-1ziso-latin-1)zlatin-1-ziso-8859-1-ziso-latin-1-r�)r5r:r7)�orig_enc�encrrr�_get_normal_namets�r�cs�z�jj�Wnty"d�Yn0d�d}d}�fdd�}��fdd�}|�}|�t�rnd�|d	d�}d
}|sz|gfS||�}|r�||gfS|�}|s�||gfS||�}|r�|||gfS|||gfS)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.
        NFrcs"z��WStyYdS0dS)Nrj)�
StopIterationr)�readlinerr�read_or_stop�sz%detect_encoding.<locals>.read_or_stopcs�z|�d�}Wn2ty@d}�dur4d�|��}t|��Yn0t�|�}|sTdSt|d�}zt|�}Wn8ty��dur�d|}nd��|�}t|��Yn0�r�|j	dkrԈdur�d}n
d���}t|��|d	7}|S)
Nrz'invalid or missing encoding declarationz{} for {!r}rzunknown encoding: zunknown encoding for {!r}: {}zencoding 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�rr�find_cookie�s8

�

z$detect_encoding.<locals>.find_cookieTrz	utf-8-sig)�__self__r~�AttributeErrorr7r�)r�r��defaultr�r��first�secondr)r�r�r�rr�s4
&


r�)r9�)r�)�unescape)�ChainMap)�MutableMapping)�recursive_repr�...cs�fdd�}|S)zm
            Decorator to make a repr function return fillvalue for a recursive
            call
            csLt�����fdd�}t�d�|_t�d�|_t�d�|_t�di�|_|S)Nc	sLt|�t�f}|�vr�S��|�z�|�}W��|�n��|�0|SrN)�id�	get_identrw�discard)rRrI�result)�	fillvalue�repr_running�
user_functionrr�wrapper�s

z=_recursive_repr.<locals>.decorating_function.<locals>.wrapperr.rUr-�__annotations__)ru�getattrr.rUr-r�)r�r��r�)r�r�r�decorating_function�sz,_recursive_repr.<locals>.decorating_functionr)r�r�rr�r�_recursive_repr�sr�c@s�eZdZdZdd�Zdd�Zdd�Zd'd	d
�Zdd�Zd
d�Z	dd�Z
dd�Ze�dd��Z
edd��Zdd�ZeZdd�Zedd��Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�ZdS)(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.

        cGst|�pig|_dS)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)rRr�rrrrTszChainMap.__init__cCst|��dSrN)�KeyError�rRrIrrr�__missing__szChainMap.__missing__c	Cs8|jD]&}z||WSty*Yq0q|�|�SrN)r�r�r�)rRrI�mappingrrr�__getitem__s
zChainMap.__getitem__NcCs||vr||S|SrNr�rRrIr�rrrrF'szChainMap.getcCstt�j|j��SrN)rGru�unionr�r�rrr�__len__*szChainMap.__len__cCstt�j|j��SrN)�iterrur�r�r�rrr�__iter__-szChainMap.__iter__cst�fdd�|jD��S)Nc3s|]}�|vVqdSrNr)re�m�rIrrri1rjz(ChainMap.__contains__.<locals>.<genexpr>�rtr�r�rr�r�__contains__0szChainMap.__contains__cCs
t|j�SrNr�r�rrr�__bool__3szChainMap.__bool__cCsd�|d�tt|j���S)Nz{0.__class__.__name__}({1})rD)r�r<rHr4r�r�rrr�__repr__6s�zChainMap.__repr__cGs|tj|g|�R��S)z?Create a ChainMap with a single dict created from the iterable.)�dict�fromkeys)�cls�iterabler�rrrr�;szChainMap.fromkeyscCs&|j|jd��g|jdd��R�S)zHNew ChainMap or subclass with a new copy of maps[0] and refs to maps[1:]rrN)�	__class__r��copyr�rrrr�@sz
ChainMap.copycCs|jig|j�R�S)z;New ChainMap with a new dict followed by all previous maps.�r�r�r�rrr�	new_childFszChainMap.new_childcCs|j|jdd��S)zNew ChainMap from maps[1:].rNr�r�rrr�parentsJszChainMap.parentscCs||jd|<dS)Nr)r�)rRrIrJrrr�__setitem__OszChainMap.__setitem__cCs6z|jd|=Wn ty0td�|���Yn0dS)Nr�(Key not found in the first mapping: {!r})r�r�r�r�rrr�__delitem__RszChainMap.__delitem__cCs0z|jd��WSty*td��Yn0dS)zPRemove and return an item pair from maps[0]. Raise KeyError is maps[0] is empty.rz#No keys found in the first mapping.N)r��popitemr�r�rrrr�XszChainMap.popitemcGs@z|jdj|g|�R�WSty:td�|���Yn0dS)zWRemove *key* from maps[0] and return its value. Raise KeyError if *key* not in maps[0].rr�N)r��popr�r�)rRrIr�rrrr�_szChainMap.popcCs|jd��dS)z'Clear maps[0], leaving maps[1:] intact.rN)r��clearr�rrrr�fszChainMap.clear)N)r-r.r/rUrTr�r�rFr�r�r�r�r�r��classmethodr�r��__copy__r��propertyr�r�r�r�r�r�rrrrr�s.



r�)�cache_from_sourcecCs0|�d�sJ�|durd}|r$d}nd}||S)Nz.pyT�c�o)rc)rX�debug_override�suffixrrrr�psr�)�OrderedDict)r�)�KeysView�
ValuesView�	ItemsViewc@s�eZdZdZdd�Zejfdd�Zejfdd�Zdd	�Zd
d�Z	dd
�Z
d6dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�ZeZe�Zefdd �Zd7d"d#�Zd8d$d%�Zd&d'�Zd(d)�Zed9d*d+��Zd,d-�Zd.d/�Zd0d1�Zd2d3�Z d4d5�Z!d!S):r�z)Dictionary that remembers insertion ordercOspt|�dkrtdt|���z
|jWn4tyZg|_}||dg|dd�<i|_Yn0|j|i|��dS)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.

            rz$expected at most 1 arguments, got %dN)rGr��_OrderedDict__rootr��_OrderedDict__map�_OrderedDict__update)rRr��kwds�rootrrrrT�s

zOrderedDict.__init__cCsF||vr6|j}|d}|||g|d<|d<|j|<||||�dS)z!od.__setitem__(i, y) <==> od[i]=yrrN)rr)rRrIrJZdict_setitemr�lastrrrr��s
 zOrderedDict.__setitem__cCs0|||�|j�|�\}}}||d<||d<dS)z od.__delitem__(y) <==> del od[y]rrN)rr�)rRrIZdict_delitem�	link_prev�	link_nextrrrr��s
zOrderedDict.__delitem__ccs.|j}|d}||ur*|dV|d}qdS)zod.__iter__() <==> iter(od)rr�N�r�rRrZcurrrrrr��s

zOrderedDict.__iter__ccs.|j}|d}||ur*|dV|d}qdS)z#od.__reversed__() <==> reversed(od)rr�Nrrrrr�__reversed__�s

zOrderedDict.__reversed__cCsbz@|j��D]}|dd�=q|j}||dg|dd�<|j��WntyRYn0t�|�dS)z.od.clear() -> None.  Remove all items from od.N)r�
itervaluesrr�r�r�)rRZnoderrrrr��szOrderedDict.clearTcCs||std��|j}|r8|d}|d}||d<||d<n |d}|d}||d<||d<|d}|j|=t�||�}||fS)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.

            zdictionary is emptyrrr�)r�rrr�r�)rRrr�linkr	r
rIrJrrrr��s 
zOrderedDict.popitemcCst|�S)zod.keys() -> list of keys in od)r�r�rrr�keys�szOrderedDict.keyscs�fdd��D�S)z#od.values() -> list of values in odcsg|]}�|�qSrr�rerIr�rrrk�rjz&OrderedDict.values.<locals>.<listcomp>rr�rr�r�values�szOrderedDict.valuescs�fdd��D�S)z.od.items() -> list of (key, value) pairs in odcsg|]}|�|f�qSrrrr�rrrk�rjz%OrderedDict.items.<locals>.<listcomp>rr�rr�r�items�szOrderedDict.itemscCst|�S)z0od.iterkeys() -> an iterator over the keys in od)r�r�rrr�iterkeys�szOrderedDict.iterkeysccs|D]}||VqdS)z2od.itervalues -> an iterator over the values in odNr�rR�krrrr�szOrderedDict.itervaluesccs|D]}|||fVqdS)z=od.iteritems -> an iterator over the (key, value) items in odNrrrrr�	iteritemsszOrderedDict.iteritemscOs�t|�dkr tdt|�f��n|s,td��|d}d}t|�dkrL|d}t|t�rn|D]}||||<qZn<t|d�r�|��D]}||||<q�n|D]\}}|||<q�|��D]\}}|||<q�dS)	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)rrrrN)rGr�rr��hasattrrr)r�rrR�otherrIrJrrrrQ	s(	�


zOrderedDict.updatecCs0||vr||}||=|S||jur,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�)rRrIr�r�rrrr�,s
zOrderedDict.popNcCs||vr||S|||<|S)zDod.setdefault(k[,d]) -> od.get(k,d), also set od[k]=d if k not in odrr�rrr�
setdefault9szOrderedDict.setdefaultcCsn|si}t|�t�f}||vr"dSd||<z6|sFd|jjfW||=Sd|jj|��fW||=S||=0dS)zod.__repr__() <==> repr(od)r�rz%s()z%s(%r)N)r��
_get_identr�r-r)rRZ
_repr_runningZcall_keyrrrr�@s��zOrderedDict.__repr__csX�fdd��D�}t����}tt��D]}|�|d�q(|rL�j|f|fS�j|ffS)z%Return state information for picklingcsg|]}|�|g�qSrr�rerr�rrrkPrjz*OrderedDict.__reduce__.<locals>.<listcomp>N)�varsr�r�r�r�)rRrZ	inst_dictrrr�r�
__reduce__NszOrderedDict.__reduce__cCs
|�|�S)z!od.copy() -> a shallow copy of od)r�r�rrrr�XszOrderedDict.copycCs|�}|D]}|||<q
|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�rJ�drIrrrr�\s
zOrderedDict.fromkeyscCs6t|t�r*t|�t|�ko(|��|��kSt�||�S)z�od.__eq__(y) <==> od==y.  Comparison to another OD is order-sensitive
            while comparison to a regular mapping is order-insensitive.

            )rr�rGrr��__eq__�rRrrrrr!gs
 zOrderedDict.__eq__cCs
||kSrNrr"rrr�__ne__pszOrderedDict.__ne__cCst|�S)z@od.viewkeys() -> a set-like object providing a view on od's keys)rr�rrr�viewkeysuszOrderedDict.viewkeyscCst|�S)z<od.viewvalues() -> an object providing a view on od's values)rr�rrr�
viewvaluesyszOrderedDict.viewvaluescCst|�S)zBod.viewitems() -> a set-like object providing a view on od's items)rr�rrr�	viewitems}szOrderedDict.viewitems)T)N)N)N)"r-r.r/rUrTr�r�r�r�r
r�r�rrrrrrrQr�objectrr�rr�rr�r�r�r!r#r$r%r&rrrrr��s:
	




	r�)�BaseConfigurator�valid_identz^[a-z_][a-z0-9_]*$cCst�|�}|std|��dS)Nz!Not a valid Python identifier: %rT)�
IDENTIFIERr>rE)rr�rrrr)�s
r)c@s"eZdZdZdd�Zddd�ZdS)�ConvertingDictz A converting dictionary wrapper.cCsJt�||�}|j�|�}||urF|||<t|�tttfvrF||_||_	|SrN)
r�r��configurator�convertr�r+�ConvertingList�ConvertingTuple�parentrI�rRrIrJr�rrrr��s
�zConvertingDict.__getitem__NcCsLt�|||�}|j�|�}||urH|||<t|�tttfvrH||_||_	|SrN)
r�rFr,r-r�r+r.r/r0rI�rRrIr�rJr�rrrrF�s
�zConvertingDict.get)N)r-r.r/rUr�rFrrrrr+�sr+cCsDt�|||�}|j�|�}||ur@t|�tttfvr@||_||_	|SrN)
r�r�r,r-r�r+r.r/r0rIr2rrrr��s
�r�c@s"eZdZdZdd�Zddd�ZdS)	r.zA converting list wrapper.cCsJt�||�}|j�|�}||urF|||<t|�tttfvrF||_||_	|SrN)
r�r�r,r-r�r+r.r/r0rIr1rrrr��s
�zConvertingList.__getitem__���cCs<t�||�}|j�|�}||ur8t|�tttfvr8||_|SrN)	r�r�r,r-r�r+r.r/r0)rR�idxrJr�rrrr��s
�zConvertingList.popN)r3)r-r.r/rUr�r�rrrrr.�sr.c@seZdZdZdd�ZdS)r/zA converting tuple wrapper.cCsBt�||�}|j�|�}||ur>t|�tttfvr>||_||_	|SrN)
�tupler�r,r-r�r+r.r/r0rIr1rrrr��s
�zConvertingTuple.__getitem__N)r-r.r/rUr�rrrrr/�sr/c@s�eZdZdZe�d�Ze�d�Ze�d�Ze�d�Z	e�d�Z
ddd	�Zee
�Zd
d�Zdd
�Zdd�Zdd�Zdd�Zdd�Zdd�ZdS)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)rfZcfgcCst|�|_||j_dSrN)r+�configr,)rRr8rrrrT�s
zBaseConfigurator.__init__c		Cs�|�d�}|�d�}z\|�|�}|D]F}|d|7}zt||�}Wq$tyh|�|�t||�}Yq$0q$|WSty�t��dd�\}}td||f�}|||_	|_
|�Yn0dS)zl
            Resolve strings to objects using standard import and attribute
            syntax.
            r0rrNzCannot resolve %r: %s)r2r��importerr�r��ImportErrorrpr�rE�	__cause__�
__traceback__)	rRrr~�used�foundrA�e�tb�vrrr�resolve�s"



zBaseConfigurator.resolvecCs
|�|�S)z*Default converter for the ext:// protocol.)rB�rRrJrrrr6szBaseConfigurator.ext_convertcCs�|}|j�|�}|dur&td|��n�||��d�}|j|��d}|r�|j�|�}|rn||��d}nb|j�|�}|r�|��d}|j�|�s�||}n0zt	|�}||}Wnt
y�||}Yn0|r�||��d�}qHtd||f��qH|S)z*Default converter for the cfg:// protocol.NzUnable to convert %rrzUnable to convert %r at %r)�WORD_PATTERNr>rE�endr8�groups�DOT_PATTERN�
INDEX_PATTERN�
DIGIT_PATTERN�intr�)rRrJ�restr�r r4�nrrrr7s4
�zBaseConfigurator.cfg_convertcCs�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�)rr+r�r,r.r�r/r5�string_types�CONVERT_PATTERNr>�	groupdict�value_convertersrFr�)rRrJr�r rMZ	converterr�rrrr-4s,
�

zBaseConfigurator.convertcsr��d�}t|�s|�|�}��dd�}t�fdd��D��}|fi|��}|rn|��D]\}}t|||�qX|S)z1Configure an object with a user-supplied factory.z()r0Ncs g|]}t|�r|�|f�qSr)r)r�r8rrrkWrjz5BaseConfigurator.configure_custom.<locals>.<listcomp>)r�r�rBr�r�setattr)rRr8r�ZpropsrSr�r~rJrrRr�configure_customPs

z!BaseConfigurator.configure_customcCst|t�rt|�}|S)z0Utility function which converts lists to tuples.)rr�r5rCrrr�as_tuple^s
zBaseConfigurator.as_tupleN)r-r.r/rUr8r;rOrDrGrHrIrQ�staticmethod�
__import__r9rTrBr6r7r-rTrUrrrrr(�s"




�"r()r)r�)N)N)�Z
__future__rrWr8rpZsslr:�version_inforZ
basestringrNrr��typesrZ	file_typeZ__builtin__�builtinsZConfigParserZconfigparserZ	_backportrrr	r
rrZurllibr
rrrrrrrZurllib2rrrrr r!r"r#r$r%ZhttplibZ	xmlrpclibZQueueZqueuer&ZhtmlentitydefsZ	raw_input�	itertoolsr'�filterr(r*�io�strr)�urllib.parseZurllib.requestZurllib.errorZhttp.clientZclientZrequestZ
xmlrpc.clientZhtml.parserZ
html.entitiesZentities�inputr+r,rErCrLrMr'rV�F_OK�X_OK�zipfilerr�rr�ZBaseZipExtFilerqr�r�r��	NameError�collections.abcr�r�r�r��getfilesystemencodingr�r��tokenizer��codecsr�r�r;r�r�Zhtmlr9Zcgir��collectionsr�r��reprlibr�r��importlib.utilr��impr��threadr�rZdummy_threadZ_abcollrrrr�Zlogging.configr(r)�Ir*r+r�r�r.r5r/rrrr�<module>s(
$,(0
2+A


		
[
b
w