ok

Mini Shell

Direktori : /lib/python3.6/site-packages/pip/compat/__pycache__/
Upload File :
Current File : //lib/python3.6/site-packages/pip/compat/__pycache__/dictconfig.cpython-36.pyc

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*	&


Zerion Mini Shell 1.0