/home/lnzliplg/public_html/compat.zip
PK(�\�j�aa#__pycache__/__init__.cpython-36.pycnu�[���3

�Pf@�0@s dZddlmZmZddlZddlZddlmZyddlm	Z
Wn ek
r`ddlm	Z
YnXyddl
mZWn ek
r�ddlmZYnXyddlZWnRek
r�yddlmZWn,ek
r�ddlZeje_eje_YnXYnXyddlZdd	�ZWn*ek
�r2dd
lmZdd	�ZYnXdd
ddddddddg
Zejd.k�rjdZddlmZn$ddlZe ed�Ze�r�ejZndZejd/k�r�dd�Z!d0dd�Z"ndd�Z!d1dd�Z"d d!�Z#d"d�Z$d#d$�Z%d2Z&ejd3k�r�e&d47Z&ej'j(d*��pej'd+k�oej)d,kZ*d-d�Z+dS)5zKStuff that differs in different Python versions and platform
distributions.�)�absolute_import�divisionN)�	text_type)�
dictConfig)�OrderedDict)�	ipaddresscCs"tjd�tjd�g}ttt|��S)N�stdlib�
platstdlib)�	sysconfig�get_path�set�filter�bool)�paths�r�/usr/lib/python3.6/__init__.py�
get_stdlib"sr)r
cCs(tjdd�tjddd�g}ttt|��S)NT)�standard_lib)rZ
plat_specific)r
Zget_python_librr
r)rrrrr+s
�logging_dictConfigr�uses_pycache�console_to_str�
native_str�get_path_uid�stdlib_pkgs�WINDOWS�samefiler��T)�cache_from_sourcercCs.y|jtjj�Stk
r(|jd�SXdS)N�utf_8)�decode�sys�
__stdout__�encoding�UnicodeDecodeError)�srrrrGsFcCs"t|t�r|jd|rdnd�S|S)Nzutf-8�replace�strict)�
isinstance�bytesr )r%r&rrrrMs
cCs|S)Nr)r%rrrrSscCst|t�r|jd�S|S)Nzutf-8)r(r�encode)r%r&rrrrVs

cCs<t|d�r|j�S|j|j|jddd}|dSdS)N�
total_seconds�i�
�i@Bi@B)�hasattrr+ZmicrosecondsZsecondsZdays)Ztd�valrrrr+]s
r+cCs`ttd�r6tj|tjtjB�}tj|�j}tj|�n&tjj	|�sPtj
|�j}ntd|��|S)a)
    Return path's uid.

    Does not follow symlinks:
        https://github.com/pypa/pip/pull/935#discussion_r5307003

    Placed this function in compat due to differences on AIX and
    Jython, that should eventually go away.

    :raises OSError: When path is a symlink or can't be read.
    �
O_NOFOLLOWz1%s is a symlink; Will not return uid for symlinks)r/�os�open�O_RDONLYr1�fstat�st_uid�close�path�islink�stat�OSError)r8�fdZfile_uidrrrres

cCs0tjj|�}|jd�r,|jd�r,|dd�}|S)zl
    Expand ~ and ~user constructions.

    Includes a workaround for http://bugs.python.org/issue14768
    z~/z//�N)r2r8�
expanduser�
startswith)r8Zexpandedrrrr>�sr>�python�wsgiref���argparse�winZcli�ntcCsNttjd�rtjj||�Stjjtjj|��}tjjtjj|��}||kSdS)z>Provide an alternative for os.path.samefile on Windows/Python2rN)r/r2r8r�normcase�abspath)Zfile1Zfile2Zpath1Zpath2rrrr�s
)rr)r)F)F)r@rA)rBrC)rD),�__doc__Z
__future__rrr2r!Zpip._vendor.sixrZlogging.configrr�ImportErrorZpip.compat.dictconfig�collectionsrZpip._vendor.ordereddictrZpip._vendorZipaddrZ	IPAddressZ
ip_addressZ	IPNetworkZ
ip_networkr
rZ	distutils�__all__�version_inforZimportlib.utilrZimpr/rrr+rr>r�platformr?�namerrrrrr�<module>sh	


PK)�\�j�aa)__pycache__/__init__.cpython-36.opt-1.pycnu�[���3

�Pf@�0@s dZddlmZmZddlZddlZddlmZyddlm	Z
Wn ek
r`ddlm	Z
YnXyddl
mZWn ek
r�ddlmZYnXyddlZWnRek
r�yddlmZWn,ek
r�ddlZeje_eje_YnXYnXyddlZdd	�ZWn*ek
�r2dd
lmZdd	�ZYnXdd
ddddddddg
Zejd.k�rjdZddlmZn$ddlZe ed�Ze�r�ejZndZejd/k�r�dd�Z!d0dd�Z"ndd�Z!d1dd�Z"d d!�Z#d"d�Z$d#d$�Z%d2Z&ejd3k�r�e&d47Z&ej'j(d*��pej'd+k�oej)d,kZ*d-d�Z+dS)5zKStuff that differs in different Python versions and platform
distributions.�)�absolute_import�divisionN)�	text_type)�
dictConfig)�OrderedDict)�	ipaddresscCs"tjd�tjd�g}ttt|��S)N�stdlib�
platstdlib)�	sysconfig�get_path�set�filter�bool)�paths�r�/usr/lib/python3.6/__init__.py�
get_stdlib"sr)r
cCs(tjdd�tjddd�g}ttt|��S)NT)�standard_lib)rZ
plat_specific)r
Zget_python_librr
r)rrrrr+s
�logging_dictConfigr�uses_pycache�console_to_str�
native_str�get_path_uid�stdlib_pkgs�WINDOWS�samefiler��T)�cache_from_sourcercCs.y|jtjj�Stk
r(|jd�SXdS)N�utf_8)�decode�sys�
__stdout__�encoding�UnicodeDecodeError)�srrrrGsFcCs"t|t�r|jd|rdnd�S|S)Nzutf-8�replace�strict)�
isinstance�bytesr )r%r&rrrrMs
cCs|S)Nr)r%rrrrSscCst|t�r|jd�S|S)Nzutf-8)r(r�encode)r%r&rrrrVs

cCs<t|d�r|j�S|j|j|jddd}|dSdS)N�
total_seconds�i�
�i@Bi@B)�hasattrr+ZmicrosecondsZsecondsZdays)Ztd�valrrrr+]s
r+cCs`ttd�r6tj|tjtjB�}tj|�j}tj|�n&tjj	|�sPtj
|�j}ntd|��|S)a)
    Return path's uid.

    Does not follow symlinks:
        https://github.com/pypa/pip/pull/935#discussion_r5307003

    Placed this function in compat due to differences on AIX and
    Jython, that should eventually go away.

    :raises OSError: When path is a symlink or can't be read.
    �
O_NOFOLLOWz1%s is a symlink; Will not return uid for symlinks)r/�os�open�O_RDONLYr1�fstat�st_uid�close�path�islink�stat�OSError)r8�fdZfile_uidrrrres

cCs0tjj|�}|jd�r,|jd�r,|dd�}|S)zl
    Expand ~ and ~user constructions.

    Includes a workaround for http://bugs.python.org/issue14768
    z~/z//�N)r2r8�
expanduser�
startswith)r8Zexpandedrrrr>�sr>�python�wsgiref���argparse�winZcli�ntcCsNttjd�rtjj||�Stjjtjj|��}tjjtjj|��}||kSdS)z>Provide an alternative for os.path.samefile on Windows/Python2rN)r/r2r8r�normcase�abspath)Zfile1Zfile2Zpath1Zpath2rrrr�s
)rr)r)F)F)r@rA)rBrC)rD),�__doc__Z
__future__rrr2r!Zpip._vendor.sixrZlogging.configrr�ImportErrorZpip.compat.dictconfig�collectionsrZpip._vendor.ordereddictrZpip._vendorZipaddrZ	IPAddressZ
ip_addressZ	IPNetworkZ
ip_networkr
rZ	distutils�__all__�version_inforZimportlib.utilrZimpr/rrr+rr>r�platformr?�namerrrrrr�<module>sh	


PK)�\�s55%__pycache__/dictconfig.cpython-36.pycnu�[���3

�Pf8Z�@s�ddlmZddlZddlZddlZddlZddlmZej	dej
�Zdd�Zyddlm
Z
Wnek
rzdd	�Z
YnXGd
d�de�ZGdd
�d
e�ZGdd�de�ZGdd�de�ZGdd�de�ZeZdd�ZdS)�)�absolute_importN)�sixz^[a-z_][a-z0-9_]*$cCstj|�}|std|��dS)Nz!Not a valid Python identifier: %rT)�
IDENTIFIER�match�
ValueError)�s�m�r	� /usr/lib/python3.6/dictconfig.py�valid_ident"s
r)�_checkLevelcCsNt|t�r|}n:t|�|kr>|tjkr2td|��tj|}ntd|��|S)NzUnknown level: %rz*Level not an integer or a valid string: %r)�
isinstance�int�str�loggingZ_levelNamesr�	TypeError)�level�rvr	r	r
r.s

rc@s,eZdZdZdd�Zd	dd�Zd
dd�ZdS)�ConvertingDictz A converting dictionary wrapper.cCsJtj||�}|jj|�}||k	rF|||<t|�tttfkrF||_||_	|S)N)
�dict�__getitem__�configurator�convert�typer�ConvertingList�ConvertingTuple�parent�key)�selfr�value�resultr	r	r
rGs
zConvertingDict.__getitem__NcCsLtj|||�}|jj|�}||k	rH|||<t|�tttfkrH||_||_	|S)N)
r�getrrrrrrrr)rr�defaultrr r	r	r
r!Ss
zConvertingDict.getcCsDtj|||�}|jj|�}||k	r@t|�tttfkr@||_||_	|S)N)
r�poprrrrrrrr)rrr"rr r	r	r
r#_s
zConvertingDict.pop)N)N)�__name__�
__module__�__qualname__�__doc__rr!r#r	r	r	r
rDs
rc@s"eZdZdZdd�Zd	dd�ZdS)
rzA converting list wrapper.cCsJtj||�}|jj|�}||k	rF|||<t|�tttfkrF||_||_	|S)N)
�listrrrrrrrrr)rrrr r	r	r
rls
zConvertingList.__getitem__�cCs<tj||�}|jj|�}||k	r8t|�tttfkr8||_|S)N)	r(r#rrrrrrr)r�idxrr r	r	r
r#xs
zConvertingList.popN���)r+)r$r%r&r'rr#r	r	r	r
rjsrc@seZdZdZdd�ZdS)rzA converting tuple wrapper.cCsBtj||�}|jj|�}||k	r>t|�tttfkr>||_||_	|S)N)
�tuplerrrrrrrrr)rrrr r	r	r
r�s
zConvertingTuple.__getitem__N)r$r%r&r'rr	r	r	r
r�src@s�eZdZdZejd�Zejd�Zejd�Zejd�Z	ejd�Z
ddd	�ZeZ
d
d�Zdd
�Zdd�Zdd�Zdd�Zdd�Zdd�ZdS)�BaseConfiguratorzI
    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)ZextZcfgcCst|�|_||j_dS)N)r�configr)rr0r	r	r
�__init__�s
zBaseConfigurator.__init__c	Cs�|jd�}|jd�}y`|j|�}xP|D]H}|d|7}yt||�}Wq&tk
rl|j|�t||�}Yq&Xq&W|Stk
r�tj�dd�\}}td||f�}|||_	|_
|�YnXdS)z`
        Resolve strings to objects using standard import and attribute
        syntax.
        �.rr)NzCannot resolve %r: %s)�splitr#�importer�getattr�AttributeError�ImportError�sys�exc_infor�	__cause__�
__traceback__)	rr�nameZused�foundZfrag�e�tb�vr	r	r
�resolve�s"




zBaseConfigurator.resolvecCs
|j|�S)z*Default converter for the ext:// protocol.)rA)rrr	r	r
r.�szBaseConfigurator.ext_convertcCs|}|jj|�}|dkr&td|��n�||j�d�}|j|j�d}x�|r�|jj|�}|rp||j�d}nd|jj|�}|r�|j�d}|jj|�s�||}n2yt	|�}||}Wnt
k
r�||}YnX|r�||j�d�}qJtd||f��qJW|S)z*Default converter for the cfg:// protocol.NzUnable to convert %rrzUnable to convert %r at %r)�WORD_PATTERNrr�endr0�groups�DOT_PATTERN�
INDEX_PATTERN�
DIGIT_PATTERNrr)rr�restr�dr*�nr	r	r
r/�s2
zBaseConfigurator.cfg_convertcCs�t|t�r&t|t�r&t|�}||_n�t|t�rLt|t�rLt|�}||_n~t|t�rrt|t�rrt|�}||_nXt|tj	�r�|j
j|�}|r�|j�}|d}|j
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.
        �prefixN�suffix)r
rrrrr(rr,rZstring_types�CONVERT_PATTERNr�	groupdict�value_convertersr!r5)rrrrIrKZ	converterrLr	r	r
r�s*

zBaseConfigurator.convertcs��jd�}t|d�r8ttd�r8t|�tjkr8|j|�}�jdd�}t�fdd��D��}|f|�}|r�x |j�D]\}}t|||�qrW|S)z1Configure an object with a user-supplied factory.z()�__call__�	ClassTyper2Nc3s"|]}t|�r|�|fVqdS)N)r)�.0�k)r0r	r
�	<genexpr>sz4BaseConfigurator.configure_custom.<locals>.<genexpr>)	r#�hasattr�typesrrQrAr�items�setattr)rr0�cZprops�kwargsr r<rr	)r0r
�configure_customs
$

z!BaseConfigurator.configure_customcCst|t�rt|�}|S)z0Utility function which converts lists to tuples.)r
r(r,)rrr	r	r
�as_tuples
zBaseConfigurator.as_tupleN)r$r%r&r'�re�compilerMrBrErFrGrO�
__import__r4r1rAr.r/rr[r\r	r	r	r
r-�s 




"r-c@s^eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	ddd�Z
ddd�Zddd�ZdS)�DictConfiguratorz]
    Configure logging using a dictionary-like object to describe the
    configuration.
    cCs�|j}d|krtd��|ddkr2td|d��|jdd�}i}tj��z||�r�|jd|�}tjdd	�dk�rx�|D]�}|tjkr�td|��qzy4tj|}||}|jdd�}|r�|j	t
|��Wqztk
�r�}	ztd
||	f��WYdd}	~	XqzXqzW|jd|�}
xZ|
D]R}y|j||
|d�Wn4tk
�rd}	ztd||	f��WYdd}	~	XnX�qW|jdd�}|�r�y|j
|d�Wn0tk
�r�}	ztd|	��WYdd}	~	XnX�n|jdd�}tjj�tjdd�=|jd|�}
xZ|
D]R}y|j|
|�|
|<Wn4tk
�rF}	ztd||	f��WYdd}	~	XnX�q�W|jd|�}xZ|D]R}y|j||�||<Wn4tk
�r�}	ztd||	f��WYdd}	~	XnX�q`W|jd|�}xht|�D]\}y |j||�}||_|||<Wn4tk
�r$}	ztd
||	f��WYdd}	~	XnX�q�Wtj}t|jj�}|j�g}|jd|�}
x�|
D]�}||k�r�|j|�}|d}t|�}t|�}|d}x<||k�r�||d|�|k�r�|j||�|d}�q�W|j|�y|j||
|�Wn4tk
�r$}	ztd||	f��WYdd}	~	XnX�q\WxF|D]>}|jj|}||k�rbtj|_g|_ d|_!n|�r2d|_"�q2W|jdd�}|�r�y|j
|�Wn0tk
�r�}	ztd|	��WYdd}	~	XnXWdtj#�XdS)zDo the configuration.�versionz$dictionary doesn't specify a versionr)zUnsupported version: %s�incrementalF�handlersN��zNo handler found with name %rrz"Unable to configure handler %r: %s�loggersTz!Unable to configure logger %r: %s�rootz#Unable to configure root logger: %sZdisable_existing_loggers�
formattersz$Unable to configure formatter %r: %s�filtersz!Unable to configure filter %r: %sr2)rdre)$r0rr#rZ_acquireLockr!r8�version_infoZ	_handlers�setLevelr�
StandardError�configure_logger�configure_root�clearZ_handlerList�configure_formatter�configure_filter�sorted�configure_handlerr<rgr(ZmanagerZ
loggerDict�sort�index�len�append�removeZNOTSETrrc�	propagateZdisabledZ_releaseLock)rr0rbZ
EMPTY_DICTrcr<ZhandlerZhandler_configrr>rfrgZdisable_existingrhriZexistingZ
child_loggers�iZprefixedZpflenZnum_existing�log�loggerr	r	r
�	configures�



"
$

$
$$



$

zDictConfigurator.configurecCs�d|krr|d}y|j|�}Wq�tk
rn}z4dt|�kr>�|jd�|d<||d<|j|�}WYdd}~Xq�Xn$|jdd�}|jdd�}tj||�}|S)z(Configure a formatter from a dictionary.z()z'format'�format�fmtNZdatefmt)r[rrr#r!rZ	Formatter)rr0�factoryr �terZdfmtr	r	r
rp�sz$DictConfigurator.configure_formattercCs.d|kr|j|�}n|jdd�}tj|�}|S)z%Configure a filter from a dictionary.z()r<�)r[r!r�Filter)rr0r r<r	r	r
rq�s

z!DictConfigurator.configure_filtercCs^xX|D]P}y|j|jd|�Wqtk
rT}ztd||f��WYdd}~XqXqWdS)z/Add filters to a filterer from a list of names.rizUnable to add filter %r: %sN)Z	addFilterr0rlr)rZfiltererri�fr>r	r	r
�add_filters�s

zDictConfigurator.add_filtersc-s@�jdd�}|rVy|jd|}Wn2tk
rT}ztd||f��WYdd}~XnX�jdd�}�jdd�}d�kr��jd�}t|d�r�ttd	�r�t|�tjkr�|j|�}|}n�|j�jd
��}t	|t
jj�o�d�k�r2y|jd�d�d<Wn8tk
�r.}ztd
�d|f��WYdd}~XnXnZt	|t
jj
��r`d�k�r`|j�d��d<n,t	|t
jj��r�d�k�r�|j�d��d<|}t�fdd��D��}	y|f|	�}
WnLtk
�r}z.dt|�k�r؂|	jd�|	d<|f|	�}
WYdd}~XnX|�r|
j|�|dk	�r*|
jt|��|�r<|j|
|�|
S)z&Configure a handler from a dictionary.�	formatterNrhzUnable to set formatter %r: %srriz()rPrQ�class�targetrcz#Unable to set target handler %r: %sZmailhostZaddressc3s"|]}t|�r|�|fVqdS)N)r)rRrS)r0r	r
rT�sz5DictConfigurator.configure_handler.<locals>.<genexpr>z'stream'�streamZstrm)r#r0rlrrUrVrrQrA�
issubclassrrcZ
MemoryHandlerZSMTPHandlerr\Z
SysLogHandlerrrrZsetFormatterrkrr�)rr0r�r>rrirYr��klassrZr r�r	)r0r
rs�sX
$

$



z"DictConfigurator.configure_handlercCs^xX|D]P}y|j|jd|�Wqtk
rT}ztd||f��WYdd}~XqXqWdS)z.Add handlers to a logger from a list of names.rczUnable to add handler %r: %sN)Z
addHandlerr0rlr)rr|rc�hr>r	r	r
�add_handlers	s

zDictConfigurator.add_handlersFcCs�|jdd�}|dk	r"|jt|��|s�x |jdd�D]}|j|�q6W|jdd�}|rd|j||�|jdd�}|r�|j||�dS)zU
        Perform configuration which is common to root and non-root loggers.
        rNrcri)r!rkrrcZ
removeHandlerr�r�)rr|r0rbrr�rcrir	r	r
�common_logger_configsz%DictConfigurator.common_logger_configcCs6tj|�}|j|||�|jdd�}|dk	r2||_dS)z.Configure a non-root logger from a dictionary.ryN)r�	getLoggerr�r!ry)rr<r0rbr|ryr	r	r
rm#s

z!DictConfigurator.configure_loggercCstj�}|j|||�dS)z*Configure a root logger from a dictionary.N)rr�r�)rr0rbrgr	r	r
rn+szDictConfigurator.configure_rootN)F)F)F)
r$r%r&r'r}rprqr�rsr�r�rmrnr	r	r	r
r`s	5

r`cCst|�j�dS)z%Configure logging using a dictionary.N)�dictConfigClassr})r0r	r	r
�
dictConfig3sr�)Z
__future__rZlogging.handlersrr]r8rVZpip._vendorrr^�Irrrr7rrr(rr,r�objectr-r`r�r�r	r	r	r
�<module>s*	&
PK)�\�s55+__pycache__/dictconfig.cpython-36.opt-1.pycnu�[���3

�Pf8Z�@s�ddlmZddlZddlZddlZddlZddlmZej	dej
�Zdd�Zyddlm
Z
Wnek
rzdd	�Z
YnXGd
d�de�ZGdd
�d
e�ZGdd�de�ZGdd�de�ZGdd�de�ZeZdd�ZdS)�)�absolute_importN)�sixz^[a-z_][a-z0-9_]*$cCstj|�}|std|��dS)Nz!Not a valid Python identifier: %rT)�
IDENTIFIER�match�
ValueError)�s�m�r	� /usr/lib/python3.6/dictconfig.py�valid_ident"s
r)�_checkLevelcCsNt|t�r|}n:t|�|kr>|tjkr2td|��tj|}ntd|��|S)NzUnknown level: %rz*Level not an integer or a valid string: %r)�
isinstance�int�str�loggingZ_levelNamesr�	TypeError)�level�rvr	r	r
r.s

rc@s,eZdZdZdd�Zd	dd�Zd
dd�ZdS)�ConvertingDictz A converting dictionary wrapper.cCsJtj||�}|jj|�}||k	rF|||<t|�tttfkrF||_||_	|S)N)
�dict�__getitem__�configurator�convert�typer�ConvertingList�ConvertingTuple�parent�key)�selfr�value�resultr	r	r
rGs
zConvertingDict.__getitem__NcCsLtj|||�}|jj|�}||k	rH|||<t|�tttfkrH||_||_	|S)N)
r�getrrrrrrrr)rr�defaultrr r	r	r
r!Ss
zConvertingDict.getcCsDtj|||�}|jj|�}||k	r@t|�tttfkr@||_||_	|S)N)
r�poprrrrrrrr)rrr"rr r	r	r
r#_s
zConvertingDict.pop)N)N)�__name__�
__module__�__qualname__�__doc__rr!r#r	r	r	r
rDs
rc@s"eZdZdZdd�Zd	dd�ZdS)
rzA converting list wrapper.cCsJtj||�}|jj|�}||k	rF|||<t|�tttfkrF||_||_	|S)N)
�listrrrrrrrrr)rrrr r	r	r
rls
zConvertingList.__getitem__�cCs<tj||�}|jj|�}||k	r8t|�tttfkr8||_|S)N)	r(r#rrrrrrr)r�idxrr r	r	r
r#xs
zConvertingList.popN���)r+)r$r%r&r'rr#r	r	r	r
rjsrc@seZdZdZdd�ZdS)rzA converting tuple wrapper.cCsBtj||�}|jj|�}||k	r>t|�tttfkr>||_||_	|S)N)
�tuplerrrrrrrrr)rrrr r	r	r
r�s
zConvertingTuple.__getitem__N)r$r%r&r'rr	r	r	r
r�src@s�eZdZdZejd�Zejd�Zejd�Zejd�Z	ejd�Z
ddd	�ZeZ
d
d�Zdd
�Zdd�Zdd�Zdd�Zdd�Zdd�ZdS)�BaseConfiguratorzI
    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)ZextZcfgcCst|�|_||j_dS)N)r�configr)rr0r	r	r
�__init__�s
zBaseConfigurator.__init__c	Cs�|jd�}|jd�}y`|j|�}xP|D]H}|d|7}yt||�}Wq&tk
rl|j|�t||�}Yq&Xq&W|Stk
r�tj�dd�\}}td||f�}|||_	|_
|�YnXdS)z`
        Resolve strings to objects using standard import and attribute
        syntax.
        �.rr)NzCannot resolve %r: %s)�splitr#�importer�getattr�AttributeError�ImportError�sys�exc_infor�	__cause__�
__traceback__)	rr�nameZused�foundZfrag�e�tb�vr	r	r
�resolve�s"




zBaseConfigurator.resolvecCs
|j|�S)z*Default converter for the ext:// protocol.)rA)rrr	r	r
r.�szBaseConfigurator.ext_convertcCs|}|jj|�}|dkr&td|��n�||j�d�}|j|j�d}x�|r�|jj|�}|rp||j�d}nd|jj|�}|r�|j�d}|jj|�s�||}n2yt	|�}||}Wnt
k
r�||}YnX|r�||j�d�}qJtd||f��qJW|S)z*Default converter for the cfg:// protocol.NzUnable to convert %rrzUnable to convert %r at %r)�WORD_PATTERNrr�endr0�groups�DOT_PATTERN�
INDEX_PATTERN�
DIGIT_PATTERNrr)rr�restr�dr*�nr	r	r
r/�s2
zBaseConfigurator.cfg_convertcCs�t|t�r&t|t�r&t|�}||_n�t|t�rLt|t�rLt|�}||_n~t|t�rrt|t�rrt|�}||_nXt|tj	�r�|j
j|�}|r�|j�}|d}|j
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.
        �prefixN�suffix)r
rrrrr(rr,rZstring_types�CONVERT_PATTERNr�	groupdict�value_convertersr!r5)rrrrIrKZ	converterrLr	r	r
r�s*

zBaseConfigurator.convertcs��jd�}t|d�r8ttd�r8t|�tjkr8|j|�}�jdd�}t�fdd��D��}|f|�}|r�x |j�D]\}}t|||�qrW|S)z1Configure an object with a user-supplied factory.z()�__call__�	ClassTyper2Nc3s"|]}t|�r|�|fVqdS)N)r)�.0�k)r0r	r
�	<genexpr>sz4BaseConfigurator.configure_custom.<locals>.<genexpr>)	r#�hasattr�typesrrQrAr�items�setattr)rr0�cZprops�kwargsr r<rr	)r0r
�configure_customs
$

z!BaseConfigurator.configure_customcCst|t�rt|�}|S)z0Utility function which converts lists to tuples.)r
r(r,)rrr	r	r
�as_tuples
zBaseConfigurator.as_tupleN)r$r%r&r'�re�compilerMrBrErFrGrO�
__import__r4r1rAr.r/rr[r\r	r	r	r
r-�s 




"r-c@s^eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	ddd�Z
ddd�Zddd�ZdS)�DictConfiguratorz]
    Configure logging using a dictionary-like object to describe the
    configuration.
    cCs�|j}d|krtd��|ddkr2td|d��|jdd�}i}tj��z||�r�|jd|�}tjdd	�dk�rx�|D]�}|tjkr�td|��qzy4tj|}||}|jdd�}|r�|j	t
|��Wqztk
�r�}	ztd
||	f��WYdd}	~	XqzXqzW|jd|�}
xZ|
D]R}y|j||
|d�Wn4tk
�rd}	ztd||	f��WYdd}	~	XnX�qW|jdd�}|�r�y|j
|d�Wn0tk
�r�}	ztd|	��WYdd}	~	XnX�n|jdd�}tjj�tjdd�=|jd|�}
xZ|
D]R}y|j|
|�|
|<Wn4tk
�rF}	ztd||	f��WYdd}	~	XnX�q�W|jd|�}xZ|D]R}y|j||�||<Wn4tk
�r�}	ztd||	f��WYdd}	~	XnX�q`W|jd|�}xht|�D]\}y |j||�}||_|||<Wn4tk
�r$}	ztd
||	f��WYdd}	~	XnX�q�Wtj}t|jj�}|j�g}|jd|�}
x�|
D]�}||k�r�|j|�}|d}t|�}t|�}|d}x<||k�r�||d|�|k�r�|j||�|d}�q�W|j|�y|j||
|�Wn4tk
�r$}	ztd||	f��WYdd}	~	XnX�q\WxF|D]>}|jj|}||k�rbtj|_g|_ d|_!n|�r2d|_"�q2W|jdd�}|�r�y|j
|�Wn0tk
�r�}	ztd|	��WYdd}	~	XnXWdtj#�XdS)zDo the configuration.�versionz$dictionary doesn't specify a versionr)zUnsupported version: %s�incrementalF�handlersN��zNo handler found with name %rrz"Unable to configure handler %r: %s�loggersTz!Unable to configure logger %r: %s�rootz#Unable to configure root logger: %sZdisable_existing_loggers�
formattersz$Unable to configure formatter %r: %s�filtersz!Unable to configure filter %r: %sr2)rdre)$r0rr#rZ_acquireLockr!r8�version_infoZ	_handlers�setLevelr�
StandardError�configure_logger�configure_root�clearZ_handlerList�configure_formatter�configure_filter�sorted�configure_handlerr<rgr(ZmanagerZ
loggerDict�sort�index�len�append�removeZNOTSETrrc�	propagateZdisabledZ_releaseLock)rr0rbZ
EMPTY_DICTrcr<ZhandlerZhandler_configrr>rfrgZdisable_existingrhriZexistingZ
child_loggers�iZprefixedZpflenZnum_existing�log�loggerr	r	r
�	configures�



"
$

$
$$



$

zDictConfigurator.configurecCs�d|krr|d}y|j|�}Wq�tk
rn}z4dt|�kr>�|jd�|d<||d<|j|�}WYdd}~Xq�Xn$|jdd�}|jdd�}tj||�}|S)z(Configure a formatter from a dictionary.z()z'format'�format�fmtNZdatefmt)r[rrr#r!rZ	Formatter)rr0�factoryr �terZdfmtr	r	r
rp�sz$DictConfigurator.configure_formattercCs.d|kr|j|�}n|jdd�}tj|�}|S)z%Configure a filter from a dictionary.z()r<�)r[r!r�Filter)rr0r r<r	r	r
rq�s

z!DictConfigurator.configure_filtercCs^xX|D]P}y|j|jd|�Wqtk
rT}ztd||f��WYdd}~XqXqWdS)z/Add filters to a filterer from a list of names.rizUnable to add filter %r: %sN)Z	addFilterr0rlr)rZfiltererri�fr>r	r	r
�add_filters�s

zDictConfigurator.add_filtersc-s@�jdd�}|rVy|jd|}Wn2tk
rT}ztd||f��WYdd}~XnX�jdd�}�jdd�}d�kr��jd�}t|d�r�ttd	�r�t|�tjkr�|j|�}|}n�|j�jd
��}t	|t
jj�o�d�k�r2y|jd�d�d<Wn8tk
�r.}ztd
�d|f��WYdd}~XnXnZt	|t
jj
��r`d�k�r`|j�d��d<n,t	|t
jj��r�d�k�r�|j�d��d<|}t�fdd��D��}	y|f|	�}
WnLtk
�r}z.dt|�k�r؂|	jd�|	d<|f|	�}
WYdd}~XnX|�r|
j|�|dk	�r*|
jt|��|�r<|j|
|�|
S)z&Configure a handler from a dictionary.�	formatterNrhzUnable to set formatter %r: %srriz()rPrQ�class�targetrcz#Unable to set target handler %r: %sZmailhostZaddressc3s"|]}t|�r|�|fVqdS)N)r)rRrS)r0r	r
rT�sz5DictConfigurator.configure_handler.<locals>.<genexpr>z'stream'�streamZstrm)r#r0rlrrUrVrrQrA�
issubclassrrcZ
MemoryHandlerZSMTPHandlerr\Z
SysLogHandlerrrrZsetFormatterrkrr�)rr0r�r>rrirYr��klassrZr r�r	)r0r
rs�sX
$

$



z"DictConfigurator.configure_handlercCs^xX|D]P}y|j|jd|�Wqtk
rT}ztd||f��WYdd}~XqXqWdS)z.Add handlers to a logger from a list of names.rczUnable to add handler %r: %sN)Z
addHandlerr0rlr)rr|rc�hr>r	r	r
�add_handlers	s

zDictConfigurator.add_handlersFcCs�|jdd�}|dk	r"|jt|��|s�x |jdd�D]}|j|�q6W|jdd�}|rd|j||�|jdd�}|r�|j||�dS)zU
        Perform configuration which is common to root and non-root loggers.
        rNrcri)r!rkrrcZ
removeHandlerr�r�)rr|r0rbrr�rcrir	r	r
�common_logger_configsz%DictConfigurator.common_logger_configcCs6tj|�}|j|||�|jdd�}|dk	r2||_dS)z.Configure a non-root logger from a dictionary.ryN)r�	getLoggerr�r!ry)rr<r0rbr|ryr	r	r
rm#s

z!DictConfigurator.configure_loggercCstj�}|j|||�dS)z*Configure a root logger from a dictionary.N)rr�r�)rr0rbrgr	r	r
rn+szDictConfigurator.configure_rootN)F)F)F)
r$r%r&r'r}rprqr�rsr�r�rmrnr	r	r	r
r`s	5

r`cCst|�j�dS)z%Configure logging using a dictionary.N)�dictConfigClassr})r0r	r	r
�
dictConfig3sr�)Z
__future__rZlogging.handlersrr]r8rVZpip._vendorrr^�Irrrr7rrr(rr,r�objectr-r`r�r�r	r	r	r
�<module>s*	&
PK)�\�'�q@@__init__.pynu�[���"""Stuff that differs in different Python versions and platform
distributions."""
from __future__ import absolute_import, division

import os
import sys

from pip._vendor.six import text_type

try:
    from logging.config import dictConfig as logging_dictConfig
except ImportError:
    from pip.compat.dictconfig import dictConfig as logging_dictConfig

try:
    from collections import OrderedDict
except ImportError:
    from pip._vendor.ordereddict import OrderedDict

try:
    import ipaddress
except ImportError:
    try:
        from pip._vendor import ipaddress
    except ImportError:
        import ipaddr as ipaddress
        ipaddress.ip_address = ipaddress.IPAddress
        ipaddress.ip_network = ipaddress.IPNetwork


try:
    import sysconfig

    def get_stdlib():
        paths = [
            sysconfig.get_path("stdlib"),
            sysconfig.get_path("platstdlib"),
        ]
        return set(filter(bool, paths))
except ImportError:
    from distutils import sysconfig

    def get_stdlib():
        paths = [
            sysconfig.get_python_lib(standard_lib=True),
            sysconfig.get_python_lib(standard_lib=True, plat_specific=True),
        ]
        return set(filter(bool, paths))


__all__ = [
    "logging_dictConfig", "ipaddress", "uses_pycache", "console_to_str",
    "native_str", "get_path_uid", "stdlib_pkgs", "WINDOWS", "samefile",
    "OrderedDict",
]


if sys.version_info >= (3, 4):
    uses_pycache = True
    from importlib.util import cache_from_source
else:
    import imp
    uses_pycache = hasattr(imp, 'cache_from_source')
    if uses_pycache:
        cache_from_source = imp.cache_from_source
    else:
        cache_from_source = None


if sys.version_info >= (3,):
    def console_to_str(s):
        try:
            return s.decode(sys.__stdout__.encoding)
        except UnicodeDecodeError:
            return s.decode('utf_8')

    def native_str(s, replace=False):
        if isinstance(s, bytes):
            return s.decode('utf-8', 'replace' if replace else 'strict')
        return s

else:
    def console_to_str(s):
        return s

    def native_str(s, replace=False):
        # Replace is ignored -- unicode to UTF-8 can't fail
        if isinstance(s, text_type):
            return s.encode('utf-8')
        return s


def total_seconds(td):
    if hasattr(td, "total_seconds"):
        return td.total_seconds()
    else:
        val = td.microseconds + (td.seconds + td.days * 24 * 3600) * 10 ** 6
        return val / 10 ** 6


def get_path_uid(path):
    """
    Return path's uid.

    Does not follow symlinks:
        https://github.com/pypa/pip/pull/935#discussion_r5307003

    Placed this function in compat due to differences on AIX and
    Jython, that should eventually go away.

    :raises OSError: When path is a symlink or can't be read.
    """
    if hasattr(os, 'O_NOFOLLOW'):
        fd = os.open(path, os.O_RDONLY | os.O_NOFOLLOW)
        file_uid = os.fstat(fd).st_uid
        os.close(fd)
    else:  # AIX and Jython
        # WARNING: time of check vulnerability, but best we can do w/o NOFOLLOW
        if not os.path.islink(path):
            # older versions of Jython don't have `os.fstat`
            file_uid = os.stat(path).st_uid
        else:
            # raise OSError for parity with os.O_NOFOLLOW above
            raise OSError(
                "%s is a symlink; Will not return uid for symlinks" % path
            )
    return file_uid


def expanduser(path):
    """
    Expand ~ and ~user constructions.

    Includes a workaround for http://bugs.python.org/issue14768
    """
    expanded = os.path.expanduser(path)
    if path.startswith('~/') and expanded.startswith('//'):
        expanded = expanded[1:]
    return expanded


# packages in the stdlib that may have installation metadata, but should not be
# considered 'installed'.  this theoretically could be determined based on
# dist.location (py27:`sysconfig.get_paths()['stdlib']`,
# py26:sysconfig.get_config_vars('LIBDEST')), but fear platform variation may
# make this ineffective, so hard-coding
stdlib_pkgs = ('python', 'wsgiref')
if sys.version_info >= (2, 7):
    stdlib_pkgs += ('argparse',)


# windows detection, covers cpython and ironpython
WINDOWS = (sys.platform.startswith("win") or
           (sys.platform == 'cli' and os.name == 'nt'))


def samefile(file1, file2):
    """Provide an alternative for os.path.samefile on Windows/Python2"""
    if hasattr(os.path, 'samefile'):
        return os.path.samefile(file1, file2)
    else:
        path1 = os.path.normcase(os.path.abspath(file1))
        path2 = os.path.normcase(os.path.abspath(file2))
        return path1 == path2
PK)�\����8Z8Z
dictconfig.pynu�[���# This is a copy of the Python logging.config.dictconfig module,
# reproduced with permission. It is provided here for backwards
# compatibility for Python versions prior to 2.7.
#
# Copyright 2009-2010 by Vinay Sajip. All Rights Reserved.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose and without fee is hereby granted,
# provided that the above copyright notice appear in all copies and that
# both that copyright notice and this permission notice appear in
# supporting documentation, and that the name of Vinay Sajip
# not be used in advertising or publicity pertaining to distribution
# of the software without specific, written prior permission.
# VINAY SAJIP DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
# ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
# VINAY SAJIP BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
# ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
# IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
# OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
from __future__ import absolute_import

import logging.handlers
import re
import sys
import types

from pip._vendor import six

# flake8: noqa

IDENTIFIER = re.compile('^[a-z_][a-z0-9_]*$', re.I)


def valid_ident(s):
    m = IDENTIFIER.match(s)
    if not m:
        raise ValueError('Not a valid Python identifier: %r' % s)
    return True

#
# This function is defined in logging only in recent versions of Python
#
try:
    from logging import _checkLevel
except ImportError:
    def _checkLevel(level):
        if isinstance(level, int):
            rv = level
        elif str(level) == level:
            if level not in logging._levelNames:
                raise ValueError('Unknown level: %r' % level)
            rv = logging._levelNames[level]
        else:
            raise TypeError('Level not an integer or a '
                            'valid string: %r' % level)
        return rv

# The ConvertingXXX classes are wrappers around standard Python containers,
# and they serve to convert any suitable values in the container. The
# conversion converts base dicts, lists and tuples to their wrapped
# equivalents, whereas strings which match a conversion format are converted
# appropriately.
#
# Each wrapper should have a configurator attribute holding the actual
# configurator to use for conversion.


class ConvertingDict(dict):
    """A converting dictionary wrapper."""

    def __getitem__(self, key):
        value = dict.__getitem__(self, key)
        result = self.configurator.convert(value)
        # If the converted value is different, save for next time
        if value is not result:
            self[key] = result
            if type(result) in (ConvertingDict, ConvertingList,
                                ConvertingTuple):
                result.parent = self
                result.key = key
        return result

    def get(self, key, default=None):
        value = dict.get(self, key, default)
        result = self.configurator.convert(value)
        # If the converted value is different, save for next time
        if value is not result:
            self[key] = result
            if type(result) in (ConvertingDict, ConvertingList,
                                ConvertingTuple):
                result.parent = self
                result.key = key
        return result

    def pop(self, key, default=None):
        value = dict.pop(self, key, default)
        result = self.configurator.convert(value)
        if value is not result:
            if type(result) in (ConvertingDict, ConvertingList,
                                ConvertingTuple):
                result.parent = self
                result.key = key
        return result


class ConvertingList(list):
    """A converting list wrapper."""
    def __getitem__(self, key):
        value = list.__getitem__(self, key)
        result = self.configurator.convert(value)
        # If the converted value is different, save for next time
        if value is not result:
            self[key] = result
            if type(result) in (ConvertingDict, ConvertingList,
                                ConvertingTuple):
                result.parent = self
                result.key = key
        return result

    def pop(self, idx=-1):
        value = list.pop(self, idx)
        result = self.configurator.convert(value)
        if value is not result:
            if type(result) in (ConvertingDict, ConvertingList,
                                ConvertingTuple):
                result.parent = self
        return result


class ConvertingTuple(tuple):
    """A converting tuple wrapper."""
    def __getitem__(self, key):
        value = tuple.__getitem__(self, key)
        result = self.configurator.convert(value)
        if value is not result:
            if type(result) in (ConvertingDict, ConvertingList,
                                ConvertingTuple):
                result.parent = self
                result.key = key
        return result


class BaseConfigurator(object):
    """
    The configurator base class which defines some useful defaults.
    """

    CONVERT_PATTERN = re.compile(r'^(?P<prefix>[a-z]+)://(?P<suffix>.*)$')

    WORD_PATTERN = re.compile(r'^\s*(\w+)\s*')
    DOT_PATTERN = re.compile(r'^\.\s*(\w+)\s*')
    INDEX_PATTERN = re.compile(r'^\[\s*(\w+)\s*\]\s*')
    DIGIT_PATTERN = re.compile(r'^\d+$')

    value_converters = {
        'ext' : 'ext_convert',
        'cfg' : 'cfg_convert',
    }

    # We might want to use a different one, e.g. importlib
    importer = __import__

    def __init__(self, config):
        self.config = ConvertingDict(config)
        self.config.configurator = self

    def resolve(self, s):
        """
        Resolve strings to objects using standard import and attribute
        syntax.
        """
        name = s.split('.')
        used = name.pop(0)
        try:
            found = self.importer(used)
            for frag in name:
                used += '.' + frag
                try:
                    found = getattr(found, frag)
                except AttributeError:
                    self.importer(used)
                    found = getattr(found, frag)
            return found
        except ImportError:
            e, tb = sys.exc_info()[1:]
            v = ValueError('Cannot resolve %r: %s' % (s, e))
            v.__cause__, v.__traceback__ = e, tb
            raise v

    def ext_convert(self, value):
        """Default converter for the ext:// protocol."""
        return self.resolve(value)

    def cfg_convert(self, value):
        """Default converter for the cfg:// protocol."""
        rest = value
        m = self.WORD_PATTERN.match(rest)
        if m is None:
            raise ValueError("Unable to convert %r" % value)
        else:
            rest = rest[m.end():]
            d = self.config[m.groups()[0]]
            # print d, rest
            while rest:
                m = self.DOT_PATTERN.match(rest)
                if m:
                    d = d[m.groups()[0]]
                else:
                    m = self.INDEX_PATTERN.match(rest)
                    if m:
                        idx = m.groups()[0]
                        if not self.DIGIT_PATTERN.match(idx):
                            d = d[idx]
                        else:
                            try:
                                n = int(idx)  # try as number first (most likely)
                                d = d[n]
                            except TypeError:
                                d = d[idx]
                if m:
                    rest = rest[m.end():]
                else:
                    raise ValueError('Unable to convert '
                                     '%r at %r' % (value, rest))
        # rest should be empty
        return d

    def convert(self, value):
        """
        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.
        """
        if not isinstance(value, ConvertingDict) and isinstance(value, dict):
            value = ConvertingDict(value)
            value.configurator = self
        elif not isinstance(value, ConvertingList) and isinstance(value, list):
            value = ConvertingList(value)
            value.configurator = self
        elif not isinstance(value, ConvertingTuple) and\
                 isinstance(value, tuple):
            value = ConvertingTuple(value)
            value.configurator = self
        elif isinstance(value, six.string_types):  # str for py3k
            m = self.CONVERT_PATTERN.match(value)
            if m:
                d = m.groupdict()
                prefix = d['prefix']
                converter = self.value_converters.get(prefix, None)
                if converter:
                    suffix = d['suffix']
                    converter = getattr(self, converter)
                    value = converter(suffix)
        return value

    def configure_custom(self, config):
        """Configure an object with a user-supplied factory."""
        c = config.pop('()')
        if not hasattr(c, '__call__') and hasattr(types, 'ClassType') and type(c) != types.ClassType:
            c = self.resolve(c)
        props = config.pop('.', None)
        # Check for valid identifiers
        kwargs = dict((k, config[k]) for k in config if valid_ident(k))
        result = c(**kwargs)
        if props:
            for name, value in props.items():
                setattr(result, name, value)
        return result

    def as_tuple(self, value):
        """Utility function which converts lists to tuples."""
        if isinstance(value, list):
            value = tuple(value)
        return value


class DictConfigurator(BaseConfigurator):
    """
    Configure logging using a dictionary-like object to describe the
    configuration.
    """

    def configure(self):
        """Do the configuration."""

        config = self.config
        if 'version' not in config:
            raise ValueError("dictionary doesn't specify a version")
        if config['version'] != 1:
            raise ValueError("Unsupported version: %s" % config['version'])
        incremental = config.pop('incremental', False)
        EMPTY_DICT = {}
        logging._acquireLock()
        try:
            if incremental:
                handlers = config.get('handlers', EMPTY_DICT)
                # incremental handler config only if handler name
                # ties in to logging._handlers (Python 2.7)
                if sys.version_info[:2] == (2, 7):
                    for name in handlers:
                        if name not in logging._handlers:
                            raise ValueError('No handler found with '
                                             'name %r'  % name)
                        else:
                            try:
                                handler = logging._handlers[name]
                                handler_config = handlers[name]
                                level = handler_config.get('level', None)
                                if level:
                                    handler.setLevel(_checkLevel(level))
                            except StandardError as e:
                                raise ValueError('Unable to configure handler '
                                                 '%r: %s' % (name, e))
                loggers = config.get('loggers', EMPTY_DICT)
                for name in loggers:
                    try:
                        self.configure_logger(name, loggers[name], True)
                    except StandardError as e:
                        raise ValueError('Unable to configure logger '
                                         '%r: %s' % (name, e))
                root = config.get('root', None)
                if root:
                    try:
                        self.configure_root(root, True)
                    except StandardError as e:
                        raise ValueError('Unable to configure root '
                                         'logger: %s' % e)
            else:
                disable_existing = config.pop('disable_existing_loggers', True)

                logging._handlers.clear()
                del logging._handlerList[:]

                # Do formatters first - they don't refer to anything else
                formatters = config.get('formatters', EMPTY_DICT)
                for name in formatters:
                    try:
                        formatters[name] = self.configure_formatter(
                                                            formatters[name])
                    except StandardError as e:
                        raise ValueError('Unable to configure '
                                         'formatter %r: %s' % (name, e))
                # Next, do filters - they don't refer to anything else, either
                filters = config.get('filters', EMPTY_DICT)
                for name in filters:
                    try:
                        filters[name] = self.configure_filter(filters[name])
                    except StandardError as e:
                        raise ValueError('Unable to configure '
                                         'filter %r: %s' % (name, e))

                # Next, do handlers - they refer to formatters and filters
                # As handlers can refer to other handlers, sort the keys
                # to allow a deterministic order of configuration
                handlers = config.get('handlers', EMPTY_DICT)
                for name in sorted(handlers):
                    try:
                        handler = self.configure_handler(handlers[name])
                        handler.name = name
                        handlers[name] = handler
                    except StandardError as e:
                        raise ValueError('Unable to configure handler '
                                         '%r: %s' % (name, e))
                # Next, do loggers - they refer to handlers and filters

                # we don't want to lose the existing loggers,
                # since other threads may have pointers to them.
                # existing is set to contain all existing loggers,
                # and as we go through the new configuration we
                # remove any which are configured. At the end,
                # what's left in existing is the set of loggers
                # which were in the previous configuration but
                # which are not in the new configuration.
                root = logging.root
                existing = list(root.manager.loggerDict)
                # The list needs to be sorted so that we can
                # avoid disabling child loggers of explicitly
                # named loggers. With a sorted list it is easier
                # to find the child loggers.
                existing.sort()
                # We'll keep the list of existing loggers
                # which are children of named loggers here...
                child_loggers = []
                # now set up the new ones...
                loggers = config.get('loggers', EMPTY_DICT)
                for name in loggers:
                    if name in existing:
                        i = existing.index(name)
                        prefixed = name + "."
                        pflen = len(prefixed)
                        num_existing = len(existing)
                        i = i + 1  # look at the entry after name
                        while (i < num_existing) and\
                              (existing[i][:pflen] == prefixed):
                            child_loggers.append(existing[i])
                            i = i + 1
                        existing.remove(name)
                    try:
                        self.configure_logger(name, loggers[name])
                    except StandardError as e:
                        raise ValueError('Unable to configure logger '
                                         '%r: %s' % (name, e))

                # Disable any old loggers. There's no point deleting
                # them as other threads may continue to hold references
                # and by disabling them, you stop them doing any logging.
                # However, don't disable children of named loggers, as that's
                # probably not what was intended by the user.
                for log in existing:
                    logger = root.manager.loggerDict[log]
                    if log in child_loggers:
                        logger.level = logging.NOTSET
                        logger.handlers = []
                        logger.propagate = True
                    elif disable_existing:
                        logger.disabled = True

                # And finally, do the root logger
                root = config.get('root', None)
                if root:
                    try:
                        self.configure_root(root)
                    except StandardError as e:
                        raise ValueError('Unable to configure root '
                                         'logger: %s' % e)
        finally:
            logging._releaseLock()

    def configure_formatter(self, config):
        """Configure a formatter from a dictionary."""
        if '()' in config:
            factory = config['()']  # for use in exception handler
            try:
                result = self.configure_custom(config)
            except TypeError as te:
                if "'format'" not in str(te):
                    raise
                # Name of parameter changed from fmt to format.
                # Retry with old name.
                # This is so that code can be used with older Python versions
                #(e.g. by Django)
                config['fmt'] = config.pop('format')
                config['()'] = factory
                result = self.configure_custom(config)
        else:
            fmt = config.get('format', None)
            dfmt = config.get('datefmt', None)
            result = logging.Formatter(fmt, dfmt)
        return result

    def configure_filter(self, config):
        """Configure a filter from a dictionary."""
        if '()' in config:
            result = self.configure_custom(config)
        else:
            name = config.get('name', '')
            result = logging.Filter(name)
        return result

    def add_filters(self, filterer, filters):
        """Add filters to a filterer from a list of names."""
        for f in filters:
            try:
                filterer.addFilter(self.config['filters'][f])
            except StandardError as e:
                raise ValueError('Unable to add filter %r: %s' % (f, e))

    def configure_handler(self, config):
        """Configure a handler from a dictionary."""
        formatter = config.pop('formatter', None)
        if formatter:
            try:
                formatter = self.config['formatters'][formatter]
            except StandardError as e:
                raise ValueError('Unable to set formatter '
                                 '%r: %s' % (formatter, e))
        level = config.pop('level', None)
        filters = config.pop('filters', None)
        if '()' in config:
            c = config.pop('()')
            if not hasattr(c, '__call__') and hasattr(types, 'ClassType') and type(c) != types.ClassType:
                c = self.resolve(c)
            factory = c
        else:
            klass = self.resolve(config.pop('class'))
            # Special case for handler which refers to another handler
            if issubclass(klass, logging.handlers.MemoryHandler) and\
                'target' in config:
                try:
                    config['target'] = self.config['handlers'][config['target']]
                except StandardError as e:
                    raise ValueError('Unable to set target handler '
                                     '%r: %s' % (config['target'], e))
            elif issubclass(klass, logging.handlers.SMTPHandler) and\
                'mailhost' in config:
                config['mailhost'] = self.as_tuple(config['mailhost'])
            elif issubclass(klass, logging.handlers.SysLogHandler) and\
                'address' in config:
                config['address'] = self.as_tuple(config['address'])
            factory = klass
        kwargs = dict((k, config[k]) for k in config if valid_ident(k))
        try:
            result = factory(**kwargs)
        except TypeError as te:
            if "'stream'" not in str(te):
                raise
            # The argument name changed from strm to stream
            # Retry with old name.
            # This is so that code can be used with older Python versions
            #(e.g. by Django)
            kwargs['strm'] = kwargs.pop('stream')
            result = factory(**kwargs)
        if formatter:
            result.setFormatter(formatter)
        if level is not None:
            result.setLevel(_checkLevel(level))
        if filters:
            self.add_filters(result, filters)
        return result

    def add_handlers(self, logger, handlers):
        """Add handlers to a logger from a list of names."""
        for h in handlers:
            try:
                logger.addHandler(self.config['handlers'][h])
            except StandardError as e:
                raise ValueError('Unable to add handler %r: %s' % (h, e))

    def common_logger_config(self, logger, config, incremental=False):
        """
        Perform configuration which is common to root and non-root loggers.
        """
        level = config.get('level', None)
        if level is not None:
            logger.setLevel(_checkLevel(level))
        if not incremental:
            # Remove any existing handlers
            for h in logger.handlers[:]:
                logger.removeHandler(h)
            handlers = config.get('handlers', None)
            if handlers:
                self.add_handlers(logger, handlers)
            filters = config.get('filters', None)
            if filters:
                self.add_filters(logger, filters)

    def configure_logger(self, name, config, incremental=False):
        """Configure a non-root logger from a dictionary."""
        logger = logging.getLogger(name)
        self.common_logger_config(logger, config, incremental)
        propagate = config.get('propagate', None)
        if propagate is not None:
            logger.propagate = propagate

    def configure_root(self, config, incremental=False):
        """Configure a root logger from a dictionary."""
        root = logging.getLogger()
        self.common_logger_config(root, config, incremental)

dictConfigClass = DictConfigurator


def dictConfig(config):
    """Configure logging using a dictionary."""
    dictConfigClass(config).configure()
PK(�\�j�aa#__pycache__/__init__.cpython-36.pycnu�[���PK)�\�j�aa)�__pycache__/__init__.cpython-36.opt-1.pycnu�[���PK)�\�s55%n__pycache__/dictconfig.cpython-36.pycnu�[���PK)�\�s55+�T__pycache__/dictconfig.cpython-36.opt-1.pycnu�[���PK)�\�'�q@@>�__init__.pynu�[���PK)�\����8Z8Z
��dictconfig.pynu�[���PK4.�