AlkantarClanX12

Your IP : 3.142.133.210


Current Path : /proc/self/root/opt/alt/python35/lib64/python3.5/logging/__pycache__/
Upload File :
Current File : //proc/self/root/opt/alt/python35/lib64/python3.5/logging/__pycache__/config.cpython-35.opt-1.pyc



��Yfh��
@sdZddlZddlZddlZddlZddlZddlZddlZddlZyddl	Z
ddlZWnek
r�dZ
YnXddl
mZmZdZejZdadddd�Zdd	�Zd
d�Zdd
�Zdd�Zdd�Zdd�Zejdej�Zdd�ZGdd�de�Z Gdd�de!e �Z"Gdd�de#e �Z$Gdd�de%e �Z&Gdd �d e�Z'Gd!d"�d"e'�Z(e(Z)d#d$�Z*edd%d&�Z+d'd(�Z,dS))a
Configuration functions for the logging package for Python. The core package
is based on PEP 282 and comments thereto in comp.lang.python, and influenced
by Apache's log4j system.

Copyright (C) 2001-2014 Vinay Sajip. All Rights Reserved.

To use, simply 'import logging' and log away!
�N)�ThreadingTCPServer�StreamRequestHandleriF#Tc
Cs�ddl}t||j�r'|}n;|j|�}t|d�rU|j|�n
|j|�t|�}tj	�z@tj
j�tjdd�=t
||�}t|||�Wdtj�XdS)aD
    Read the logging configuration from a ConfigParser-format file.

    This can be called several times from an application, allowing an end user
    the ability to select from various pre-canned configurations (if the
    developer provides a mechanism to present the choices and load the chosen
    configuration).
    rN�readline)�configparser�
isinstanceZRawConfigParserZConfigParser�hasattrZ	read_file�read�_create_formatters�logging�_acquireLock�	_handlers�clear�_handlerList�_install_handlers�_install_loggers�_releaseLock)ZfnameZdefaults�disable_existing_loggersr�cp�
formatters�handlers�r�3/opt/alt/python35/lib64/python3.5/logging/config.py�
fileConfig8s		


rcCs�|jd�}|jd�}t|�}x]|D]U}|d|}yt||�}Wq1tk
r�t|�t||�}Yq1Xq1W|S)z)Resolve a dotted name to a global object.�.r)�split�pop�
__import__�getattr�AttributeError)�name�used�found�nrrr�_resolveZs


r#cCstdd�|�S)NcSs
|j�S)N)�strip)�xrrr�<lambda>isz_strip_spaces.<locals>.<lambda>)�map)Zalistrrr�
_strip_spaceshsr(cCs|dd}t|�siS|jd�}t|�}i}x�|D]�}d|}|j|ddddd	�}|j|d
dddd	�}|j|ddddd�}tj}||jd
�}	|	r�t|	�}||||�}
|
||<qFW|S)zCreate and return formattersr�keys�,zformatter_%s�format�rawT�fallbackN�datefmt�style�%�class)�lenrr(�getr
�	Formatterr#)rZflistrZformZsectnameZfsZdfsZstl�cZ
class_name�frrrr	ks$

	r	c
Cs�|dd}t|�siS|jd�}t|�}i}g}x3|D]+}|d|}|d}|jdd�}yt|tt��}Wn$ttfk
r�t	|�}YnX|d}	t|	tt��}	||	�}
d	|kr
|d	}|
j
|�t|�r'|
j||�t|tj
j�rm|jd
d�}t|�rm|j|
|f�|
||<qLWx%|D]\}
}
|
j||
�q�W|S)zInstall and return handlersrr)r*z
handler_%sr1�	formatter��args�level�target)r2rr(r3�eval�varsr
r�	NameErrorr#�setLevel�setFormatter�
issubclassr�
MemoryHandler�appendZ	setTarget)rr�hlistrZfixups�hand�section�klass�fmtr9�hr:r;�trrrr�s>




rcCsdtj}xT|D]L}|jj|}||krStj|_g|_d|_q||_qWdS)a�
    When (re)configuring logging, handle loggers which were in the previous
    configuration but are not in the new configuration. There's no point
    deleting them as other threads may continue to hold references to them;
    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. Also, allow existing loggers to NOT be
    disabled if disable_existing is false.
    TN)	r
�root�manager�
loggerDictZNOTSETr:r�	propagate�disabled)�existing�
child_loggers�disable_existingrK�log�loggerrrr�_handle_existing_loggers�s	
	rUcCs�|dd}|jd�}ttdd�|��}|jd�|d}tj}|}d|kr�|d}|j|�x(|jd	d	�D]}|j|�q�W|d
}	t	|	�r�|	jd�}	t
|	�}	x|	D]}
|j||
�q�Wt|jj
j��}|j�g}x�|D]�}|d|}|d}
|jd
dd�}tj|
�}|
|kr|j|
�d}|
d}t	|�}t	|�}xE||kr�||d	|�|kr�|j||�|d7}q�W|j|
�d|kr)|d}|j|�x(|jd	d	�D]}|j|�q=W||_d|_|d
}	t	|	�r.|	jd�}	t
|	�}	x|	D]}
|j||
�q�Wq.Wt|||�d	S)zCreate and install loggers�loggersr)r*cSs
|j�S)N)r$)r%rrrr&�sz"_install_loggers.<locals>.<lambda>rKZlogger_rootr:Nrz	logger_%sZqualnamerNr-�rr)r�listr'�remover
rKr?r�
removeHandlerr2r(�
addHandlerrLrMr)�sortZgetint�	getLogger�indexrCrNrOrU)rrrRZllistrFrKrSr:rIrDrErPrQZqnrNrT�i�prefixed�pflen�num_existingrrrr�sd

	










		

rz^[a-z_][a-z0-9_]*$cCs)tj|�}|s%td|��dS)Nz!Not a valid Python identifier: %rT)�
IDENTIFIER�match�
ValueError)�s�mrrr�valid_identsrhc@s1eZdZdZddd�Zdd�ZdS)�ConvertingMixinz?For ConvertingXXX's, this mixin class provides common functionsTcCs_|jj|�}||k	r[|r.|||<t|�tttfkr[||_||_|S)N)�configurator�convert�type�ConvertingDict�ConvertingList�ConvertingTuple�parent�key)�selfrq�value�replace�resultrrr�convert_with_keys
		z ConvertingMixin.convert_with_keycCsF|jj|�}||k	rBt|�tttfkrB||_|S)N)rjrkrlrmrnrorp)rrrsrurrrrk(s	zConvertingMixin.convertN)�__name__�
__module__�__qualname__�__doc__rvrkrrrrrisric@s@eZdZdZdd�Zddd�Zddd�ZdS)	rmz A converting dictionary wrapper.cCs"tj||�}|j||�S)N)�dict�__getitem__rv)rrrqrsrrrr|=szConvertingDict.__getitem__NcCs%tj|||�}|j||�S)N)r{r3rv)rrrq�defaultrsrrrr3AszConvertingDict.getcCs+tj|||�}|j||dd�S)NrtF)r{rrv)rrrqr}rsrrrrEszConvertingDict.pop)rwrxryrzr|r3rrrrrrm:srmc@s1eZdZdZdd�Zddd�ZdS)	rnzA converting list wrapper.cCs"tj||�}|j||�S)N)rXr|rv)rrrqrsrrrr|KszConvertingList.__getitem__rWcCstj||�}|j|�S)N)rXrrk)rr�idxrsrrrrOszConvertingList.popN���)rwrxryrzr|rrrrrrnIsrnc@s"eZdZdZdd�ZdS)rozA converting tuple wrapper.cCs(tj||�}|j||dd�S)NrtF)�tupler|rv)rrrqrsrrrr|UszConvertingTuple.__getitem__N)rwrxryrzr|rrrrroSsroc@s�eZdZdZejd�Zejd�Zejd�Zejd�Z	ejd�Z
ddd	d
iZee
�Zdd�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+$Zext�ext_convertZcfg�cfg_convertcCst|�|_||j_dS)N)rm�configrj)rrr�rrr�__init__nszBaseConfigurator.__init__c	Cs�|jd�}|jd�}yz|j|�}x`|D]X}|d|7}yt||�}Wq7tk
r�|j|�t||�}Yq7Xq7W|SWn]tk
r�tj�dd�\}}td||f�}|||_	|_
|�YnXdS)z`
        Resolve strings to objects using standard import and attribute
        syntax.
        rrrWNzCannot resolve %r: %s)rr�importerrr�ImportError�sys�exc_infore�	__cause__�
__traceback__)	rrrfrr r!Zfrag�e�tb�vrrr�resolvers"



zBaseConfigurator.resolvecCs
|j|�S)z*Default converter for the ext:// protocol.)r�)rrrsrrrr��szBaseConfigurator.ext_convertcCsY|}|jj|�}|dkr7td|��n||j�d�}|j|j�d}x�|rT|jj|�}|r�||j�d}n�|jj|�}|r|j�d}|jj|�s�||}n9yt	|�}||}Wnt
k
r||}YnX|r;||j�d�}qgtd||f��qgW|S)z*Default converter for the cfg:// protocol.NzUnable to convert %rrzUnable to convert %r at %r)�WORD_PATTERNrdre�endr��groups�DOT_PATTERN�
INDEX_PATTERN�
DIGIT_PATTERN�int�	TypeError)rrrs�restrg�dr~r"rrrr��s2	

zBaseConfigurator.cfg_convertcCs&t|t�r7t|t�r7t|�}||_n�t|t�rnt|t�rnt|�}||_n�t|t�r�t|t�r�t|�}||_n}t|t�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)rrmr{rjrnrXror��str�CONVERT_PATTERNrd�	groupdict�value_convertersr3r)rrrsrgr�r�Z	converterr�rrrrk�s*

zBaseConfigurator.convertcs��jd�}t|�s*|j|�}�jdd�}t�fdd��D��}||�}|r�x*|j�D]\}}t|||�qzW|S)z1Configure an object with a user-supplied factory.z()rNcs,g|]"}t|�r|�|f�qSr)rh)�.0�k)r�rr�
<listcomp>�s	z5BaseConfigurator.configure_custom.<locals>.<listcomp>)r�callabler�r{�items�setattr)rrr�r5�props�kwargsrurrsr)r�r�configure_custom�sz!BaseConfigurator.configure_customcCst|t�rt|�}|S)z0Utility function which converts lists to tuples.)rrXr�)rrrsrrr�as_tuple�szBaseConfigurator.as_tupleN)rwrxryrz�re�compiler�r�r�r�r�r��staticmethodrr�r�r�r�r�rkr�r�rrrrr�Zs "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|kr!td��|ddkrEtd|d��|jdd�}i}tj�z�|r|jd|�}x�|D]�}|tjkr�td|��q�yItj|}||}|jd	d
�}|r�|jtj|��Wq�t	k
r7}	ztd||	f��WYd
d
}	~	Xq�Xq�W|jd|�}
xg|
D]_}y|j
||
|d
�WqUt	k
r�}	ztd||	f��WYd
d
}	~	XqUXqUW|jdd
�}|r)y|j|d
�Wq)t	k
r}	ztd|	��WYd
d
}	~	Xq)Xn
|jdd
�}tjj�tj
d
d
�=|jd|�}
xg|
D]_}y|j|
|�|
|<Wqgt	k
r�}	ztd||	f��WYd
d
}	~	XqgXqgW|jd|�}xg|D]_}y|j||�||<Wq�t	k
rA}	ztd||	f��WYd
d
}	~	Xq�Xq�W|jd|�}g}x�t|�D]�}y*|j||�}||_|||<Wqkt	k
r�}	z=dt|	�kr�|j|�ntd||	f��WYd
d
}	~	XqkXqkWxv|D]n}y*|j||�}||_|||<Wqt	k
rs}	ztd||	f��WYd
d
}	~	XqXqWtj}t|jjj��}|j�g}|jd|�}
x�|
D]�}||kr^|j|�d}|d}t|�}t|�}xE||krP||d
|�|krC|j||�|d7}qW|j|�y|j
||
|�Wq�t	k
r�}	ztd||	f��WYd
d
}	~	Xq�Xq�Wt|||�|jdd
�}|r)y|j|�Wn5t	k
r(}	ztd|	��WYd
d
}	~	XnXWd
tj�Xd
S)zDo the configuration.�versionz$dictionary doesn't specify a versionrWzUnsupported version: %s�incrementalFrzNo handler found with name %rr:Nz"Unable to configure handler %r: %srVTz!Unable to configure logger %r: %srKz#Unable to configure root logger: %srrz$Unable to configure formatter %r: %s�filtersz!Unable to configure filter %r: %sztarget not configured yetr) r�rerr
rr3rr?�_checkLevel�	Exception�configure_logger�configure_rootr
r�configure_formatter�configure_filter�sorted�configure_handlerrr�rCrKrXrLrMr)r\r^r2rYrUr)rrr�r�Z
EMPTY_DICTrr�handlerZhandler_configr:r�rVrKrRrr�ZdeferredrPrQr_r`rarbrrr�	configure�s�	




'
' 

'
'	'
	'	



'	!zDictConfigurator.configurec
Csd|kr�|d}y|j|�}Wq
tk
r�}zFdt|�krS�|jd�|d<||d<|j|�}WYdd}~Xq
Xnx|jdd�}|jdd�}|jdd�}|jd	d�}|s�tj}	nt|�}	|	|||�}|S)
z(Configure a formatter from a dictionary.z()z'format'r+rHNr.r/r0r1)r�r�r�rr3r
r4r#)
rrr��factoryru�terHZdfmtr/�cnamer5rrrr��s&

%z$DictConfigurator.configure_formattercCsCd|kr|j|�}n!|jdd�}tj|�}|S)z%Configure a filter from a dictionary.z()rr8)r�r3r
ZFilter)rrr�rurrrrr��s
z!DictConfigurator.configure_filtercCsoxh|D]`}y|j|jd|�Wqtk
rf}ztd||f��WYdd}~XqXqWdS)z/Add filters to a filterer from a list of names.r�zUnable to add filter %r: %sN)Z	addFilterr�r�re)rrZfiltererr�r6r�rrr�add_filters�s

zDictConfigurator.add_filtersc/sDt��}�jdd�}|rwy|jd|}Wn;tk
rv}ztd||f��WYdd}~XnX�jdd�}�jdd�}d�kr��jd�}t|�s�|j|�}|}nK�jd�}	|j|	�}
t|
tj	j
�r�d	�kr�yN|jd
�d	}t|tj�s\�j
|�td��|�d	<Wqtk
r�}ztd�d	|f��WYdd}~XqXnst|
tj	j�r�d
�kr�|j�d
��d
<n8t|
tj	j�rd�kr|j�d��d<|
}�jdd�}t�fdd��D��}
y||
�}WnYtk
r�}z9dt|�kr��|
jd�|
d<||
�}WYdd}~XnX|r�|j|�|dk	r�|jtj|��|r
|j||�|r@x*|j�D]\}}t|||�q W|S)z&Configure a handler from a dictionary.r7NrzUnable to set formatter %r: %sr:r�z()r1r;rztarget not configured yetz#Unable to set target handler %r: %sZmailhostZaddressrcs,g|]"}t|�r|�|f�qSr)rh)r�r�)r�rrr��s	z6DictConfigurator.configure_handler.<locals>.<listcomp>z'stream'�streamZstrm)r{rr�r�rer�r�rAr
rrBrZHandler�updater�ZSMTPHandlerr�Z
SysLogHandlerr�r@r?r�r�r�r�)rrr�Zconfig_copyr7r�r:r�r5r�r�rGZthr�r�rur�rrsr)r�rr��sl#	
*
z"DictConfigurator.configure_handlercCsoxh|D]`}y|j|jd|�Wqtk
rf}ztd||f��WYdd}~XqXqWdS)z.Add handlers to a logger from a list of names.rzUnable to add handler %r: %sN)r[r�r�re)rrrTrrIr�rrr�add_handlers�s

zDictConfigurator.add_handlersFcCs�|jdd�}|dk	r4|jtj|��|s�x(|jdd�D]}|j|�qNW|jdd�}|r�|j||�|jdd�}|r�|j||�dS)zU
        Perform configuration which is common to root and non-root loggers.
        r:Nrr�)r3r?r
r�rrZr�r�)rrrTr�r�r:rIrr�rrr�common_logger_config�sz%DictConfigurator.common_logger_configcCsMtj|�}|j|||�|jdd�}|dk	rI||_dS)z.Configure a non-root logger from a dictionary.rNN)r
r]r�r3rN)rrrr�r�rTrNrrrr�
s
z!DictConfigurator.configure_loggercCs#tj�}|j|||�dS)z*Configure a root logger from a dictionary.N)r
r]r�)rrr�r�rKrrrr�szDictConfigurator.configure_rootN)
rwrxryrzr�r�r�r�r�r�r�r�r�rrrrr��s�	?r�cCst|�j�dS)z%Configure logging using a dictionary.N)�dictConfigClassr�)r�rrr�
dictConfigsr�csptstd��Gdd�dt�}Gdd�dt�}G�fdd�dtj���||||�S)au
    Start up a socket server on the specified port, and listen for new
    configurations.

    These will be sent as a file suitable for processing by fileConfig().
    Returns a Thread object on which you can call start() to start the server,
    and which you can join() when appropriate. To stop the server, call
    stopListening().

    Use the ``verify`` argument to verify any bytes received across the wire
    from a client. If specified, it should be a callable which receives a
    single argument - the bytes of configuration data received across the
    network - and it should return either ``None``, to indicate that the
    passed in bytes could not be verified and should be discarded, or a
    byte string which is then passed to the configuration machinery as
    normal. Note that you can return transformed bytes, e.g. by decrypting
    the bytes passed in.
    z listen() needs threading to workc@s"eZdZdZdd�ZdS)z#listen.<locals>.ConfigStreamHandlerz�
        Handler for a logging configuration request.

        It expects a completely new logging configuration and uses fileConfig
        to install it.
        cSs�ya|j}|jd�}t|�dkr`tjd|�d}|jj|�}x3t|�|kr�||j|t|��}qXW|jjdk	r�|jj|�}|dk	rD|jd�}y)ddl}|j	|�}t
|�WnNtk
rCtj
|�}yt|�Wntk
r>tj�YnXYnX|jjr`|jjj�Wn7tk
r�}z|jtkr��WYdd}~XnXdS)z�
            Handle a request.

            Each request is expected to be a 4-byte length, packed using
            struct.pack(">L", n), followed by the config file.
            Uses fileConfig() to do the grunt work.
            �z>LrNzutf-8)Z
connectionZrecvr2�structZunpack�server�verify�decode�json�loadsr�r��io�StringIOr�	traceback�	print_exc�ready�set�OSError�errno�RESET_ERROR)rrZconn�chunkZslenr�r��filer�rrr�handle;s6	!

z*listen.<locals>.ConfigStreamHandler.handleN)rwrxryrzr�rrrr�ConfigStreamHandler4sr�c@sCeZdZdZdZdeddddd�Zdd�ZdS)	z$listen.<locals>.ConfigSocketReceiverzD
        A simple TCP socket-based logging config receiver.
        rWZ	localhostNcSsUtj|||f|�tj�d|_tj�d|_||_||_dS)NrrW)	rr�r
r�abortr�timeoutr�r�)rr�host�portr�r�r�rrrr�is
	
		z-listen.<locals>.ConfigSocketReceiver.__init__cSs�ddl}d}xg|s{|j|jj�ggg|j�\}}}|r[|j�tj�|j}tj�qW|jj	�dS)Nr)
�selectZsocket�filenor�Zhandle_requestr
rr�r�close)rrr�r�Zrd�wrZexrrr�serve_until_stoppedss	

	z8listen.<locals>.ConfigSocketReceiver.serve_until_stopped)rwrxryrzZallow_reuse_address�DEFAULT_LOGGING_CONFIG_PORTr�r�rrrr�ConfigSocketReceiverbs
	r�cs1eZdZ��fdd�Zdd�Z�S)zlisten.<locals>.ServercsJt�|�j�||_||_||_||_tj�|_dS)N)	�superr��rcvr�hdlrr�r��	threadingZEventr�)rrr�r�r�r�)�Server�	__class__rrr��s				zlisten.<locals>.Server.__init__c	Ss�|jd|jd|jd|jd|j�}|jdkrO|jd|_|jj�tj�|a	tj
�|j�dS)Nr�r�r�r�rrW)r�r�r�r�r�Zserver_addressr�r
r�	_listenerrr�)rrr�rrr�run�s	


zlisten.<locals>.Server.run)rwrxryr�r�r)r�)r�rr��sr�)�thread�NotImplementedErrorrrr�ZThread)r�r�r�r�r)r�r�listens.r�c
Cs5tj�ztr"dt_daWdtj�XdS)zN
    Stop the listening server which was created with a call to listen().
    rWN)r
rr�r�rrrrr�
stopListening�s
	
r�)-rzr�r�r
Zlogging.handlersr�r�r�r��_threadr�r�r�Zsocketserverrrr�Z
ECONNRESETr�r�rr#r(r	rrUrr��Ircrh�objectrir{rmrXrnr�ror�r�r�r�r�r�rrrr�<module>sJ
	"#V!
��9|