ok

Mini Shell

Direktori : /proc/self/root/usr/lib64/python3.6/logging/__pycache__/
Upload File :
Current File : //proc/self/root/usr/lib64/python3.6/logging/__pycache__/config.cpython-36.opt-1.pyc

3


 \Ќ�
@stdZddlZddlZddlZddlZddlZddlZddlZddlZyddl	Z
ddlZWnek
rpdZ
YnXddl
mZmZdZejZdad+dd�Zdd	�Zd
d�Zdd
�Zdd�Zdd�Zdd�Zdd�Zejdej�Zdd�ZGdd�de �Z!Gdd�de"e!�Z#Gdd�de$e!�Z%Gdd �d e&e!�Z'Gd!d"�d"e �Z(Gd#d$�d$e(�Z)e)Z*d%d&�Z+edfd'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�r:|j|�n
|j|�t|�}tj	�z t
�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�_clearExistingHandlers�_install_handlers�_install_loggers�_releaseLock)ZfnameZdefaults�disable_existing_loggersr�cp�
formatters�handlers�r�/usr/lib64/python3.6/config.py�
fileConfig8s	



rcCsp|jd�}|jd�}t|�}xN|D]F}|d|}yt||�}Wq"tk
rft|�t||�}Yq"Xq"W|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]v}d|}|j|dddd�}|j|d	ddd�}|j|d
ddd�}tj}||jd�}	|	r�t|	�}||||�}
|
||<q4W|S)
zCreate and return formattersr�keys�,zformatter_%s�formatTN)�raw�fallback�datefmt�style�%�class)�lenrr&�getr
�	Formatterr!)r�flistrZformZsectnameZfsZdfsZstl�c�
class_name�frrrr	ks$

r	c
CsD|dd}t|�siS|jd�}t|�}i}g}x�|D]�}|d|}|d}|jdd�}yt|tt��}Wn ttfk
r�t	|�}YnX|d}	t|	tt��}	||	�}
d	|kr�|d	}|
j
|�t|�r�|
j||�t|tj
j��r|jd
d�}t|��r|j|
|f�|
||<q8Wx |D]\}
}
|
j||
��q$W|S)zInstall and return handlersrr'r(z
handler_%sr/�	formatter��args�level�target)r0rr&r1�eval�varsr
r�	NameErrorr!�setLevel�setFormatter�
issubclassr�
MemoryHandler�appendZ	setTarget)rr�hlistrZfixups�hand�section�klass�fmtr9�hr:r;�trrrr
�s>



r
cCsHtj}x<|D]4}|jj|}||kr:tj|_g|_d|_q||_qWdS)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|�qnW|d
}	t	|	�r�|	jd�}	t
|	�}	x|	D]}
|j||
�q�Wt|jj
j��}|j�g}�x>|D�]4}|d|}|d}
|jd
dd�}tj|
�}|
|k�r�|j|
�d}|
d}t	|�}t	|�}x<||k�r�||d	|�|k�rt|j||�|d7}�qFW|j|
�d|k�r�|d}|j|�x"|jd	d	�D]}|j|��q�W||_d|_|d
}	t	|	�r�|	jd�}	t
|	�}	x|	D]}
|j||
��qWq�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_%s�qualnamerN�)r+rr)r�listr%�remover
rKr?r�
removeHandlerr0r&�
addHandlerrLrMr'�sortZgetint�	getLogger�indexrCrNrOrU)rrrRZllistrFrKrSr:rIrDrErPrQZqnrNrT�i�prefixed�pflen�num_existingrrrr�sd











rcCs.tjj�tjtjdd��tjdd�=dS)z!Clear and close existing handlersN)r
�	_handlers�clearZshutdownZ_handlerListrrrrrs
rz^[a-z_][a-z0-9_]*$cCstj|�}|std|��dS)Nz!Not a valid Python identifier: %rT)�
IDENTIFIER�match�
ValueError)�s�mrrr�valid_idents
rkc@s"eZdZdZddd�Zdd�ZdS)	�ConvertingMixinz?For ConvertingXXX's, this mixin class provides common functionsTcCsB|jj|�}||k	r>|r |||<t|�tttfkr>||_||_|S)N)�configurator�convert�type�ConvertingDict�ConvertingList�ConvertingTuple�parent�key)�selfrt�value�replace�resultrrr�convert_with_key$s
z ConvertingMixin.convert_with_keycCs0|jj|�}||k	r,t|�tttfkr,||_|S)N)rmrnrorprqrrrs)rurvrxrrrrn0s
zConvertingMixin.convertN)T)�__name__�
__module__�__qualname__�__doc__ryrnrrrrrl!s
rlc@s,eZdZdZdd�Zd	dd�Zd
dd�ZdS)rpz A converting dictionary wrapper.cCstj||�}|j||�S)N)�dict�__getitem__ry)rurtrvrrrrEszConvertingDict.__getitem__NcCstj|||�}|j||�S)N)r~r1ry)rurt�defaultrvrrrr1IszConvertingDict.getcCstj|||�}|j||dd�S)NF)rw)r~rry)rurtr�rvrrrrMszConvertingDict.pop)N)N)rzr{r|r}rr1rrrrrrpBs
rpc@s"eZdZdZdd�Zd	dd�ZdS)
rqzA converting list wrapper.cCstj||�}|j||�S)N)rYrry)rurtrvrrrrSszConvertingList.__getitem__rXcCstj||�}|j|�S)N)rYrrn)ru�idxrvrrrrWszConvertingList.popN���)r�)rzr{r|r}rrrrrrrqQsrqc@seZdZdZdd�ZdS)rrzA converting tuple wrapper.cCstj||�}|j||dd�S)NF)rw)�tuplerry)rurtrvrrrr]szConvertingTuple.__getitem__N)rzr{r|r}rrrrrrr[srrc@s�eZdZdZejd�Zejd�Zejd�Zejd�Z	ejd�Z
ddd	�Zee
�Zd
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)rp�configrm)rur�rrr�__init__vs
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.
        rrrXNzCannot resolve %r: %s)rr�importerrr�ImportError�sys�exc_inforh�	__cause__�
__traceback__)	rurirrrZfrag�e�tb�vrrr�resolvezs"




zBaseConfigurator.resolvecCs
|j|�S)z*Default converter for the ext:// protocol.)r�)rurvrrrr��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_PATTERNrgrh�endr��groups�DOT_PATTERN�
INDEX_PATTERN�
DIGIT_PATTERN�int�	TypeError)rurv�restrj�dr�r rrrr��s2
zBaseConfigurator.cfg_convertcCs�t|t�r&t|t�r&t|�}||_n�t|t�rLt|t�rLt|�}||_n|t|t�rrt|t�rrt|�}||_nVt|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)rrpr~rmrqrYrrr��str�CONVERT_PATTERNrg�	groupdict�value_convertersr1r)rurvrjr�r�Z	converterr�rrrrn�s*


zBaseConfigurator.convertcsr�jd�}t|�s|j|�}�jdd�}t�fdd��D��}|f|�}|rnx |j�D]\}}t|||�qVW|S)z1Configure an object with a user-supplied factory.z()rNcs g|]}t|�r|�|f�qSr)rk)�.0�k)r�rr�
<listcomp>�sz5BaseConfigurator.configure_custom.<locals>.<listcomp>)r�callabler�r~�items�setattr)rur�r4�props�kwargsrxrrvr)r�r�configure_custom�s


z!BaseConfigurator.configure_customcCst|t�rt|�}|S)z0Utility function which converts lists to tuples.)rrYr�)rurvrrr�as_tuple�s
zBaseConfigurator.as_tupleN)rzr{r|r}�re�compiler�r�r�r�r�r��staticmethodrr�r�r�r�r�rnr�r�rrrrr�bs 




"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|�}x�|D]�}|tjkr�td|��qfy6tj|}||}|jd	d
�}|r�|jtj|��Wqft	k
r�}	ztd||	f��WYd
d
}	~	XqfXqfW|jd|�}
xZ|
D]R}y|j
||
|d
�Wn4t	k
�rP}	ztd||	f��WYd
d
}	~	XnX�qW|jdd
�}|�r�y|j|d
�Wn0t	k
�r�}	ztd|	��WYd
d
}	~	XnX�n:|jdd
�}t�|jd|�}
xZ|
D]R}y|j
|
|�|
|<Wn4t	k
�r"}	ztd||	f��WYd
d
}	~	XnX�q�W|jd|�}xZ|D]R}y|j||�||<Wn4t	k
�r�}	ztd||	f��WYd
d
}	~	XnX�q<W|jd|�}g}x�t|�D]v}y |j||�}||_|||<WnNt	k
�r}	z0dt|	�k�r�|j|�ntd||	f��WYd
d
}	~	XnX�q�Wxd|D]\}y |j||�}||_|||<Wn4t	k
�r�}	ztd||	f��WYd
d
}	~	XnX�q,Wtj}t|jjj��}|j�g}|jd|�}
x�|
D]�}||k�r<|j|�d}|d}t|�}t|�}x<||k�r0||d
|�|k�r$|j||�|d7}�q�W|j|�y|j
||
|�Wn4t	k
�r�}	ztd||	f��WYd
d
}	~	XnX�q�Wt|||�|jdd
�}|�r�y|j|�Wn0t	k
�r�}	ztd|	��WYd
d
}	~	XnXWd
tj�Xd
S)zDo the configuration.�versionz$dictionary doesn't specify a versionrXzUnsupported 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�rhrr
rr1rdr?�_checkLevel�	Exception�configure_logger�configure_rootr�configure_formatter�configure_filter�sorted�configure_handlerrr�rCrKrYrLrMr'r]r_r0rZrUr)rur�r�Z
EMPTY_DICTrr�handlerZhandler_configr:r�rVrKrRrr�ZdeferredrPrQr`rarbrcrrr�	configure�s�



"
$
$
$$
$


$zDictConfigurator.configurec
Cs�d|krr|d}y|j|�}Wq�tk
rn}z4dt|�kr>�|jd�|d<||d<|j|�}WYdd}~Xq�XnP|jdd�}|jdd�}|jdd�}|jd	d�}|s�tj}	nt|�}	|	|||�}|S)
z(Configure a formatter from a dictionary.z()z'format'r)rHNr,r-r.r/)r�r�r�rr1r
r2r!)
rur��factoryrx�terHZdfmtr-�cnamer4rrrr��s&z$DictConfigurator.configure_formattercCs.d|kr|j|�}n|jdd�}tj|�}|S)z%Configure a filter from a dictionary.z()rr8)r�r1r
ZFilter)rur�rxrrrrr��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.r�zUnable to add filter %r: %sN)Z	addFilterr�r�rh)ruZfiltererr�r6r�rrr�add_filters�s

zDictConfigurator.add_filtersc/s�t��}�jdd�}|r^y|jd|}Wn2tk
r\}ztd||f��WYdd}~XnX�jdd�}�jdd�}d�kr��jd�}t|�s�|j|�}|}�n�jd�}	|j|	�}
t|
tj	j
�o�d	�k�rHy>|jd
�d	}t|tj��s�j
|�td��|�d	<Wn8tk
�rD}ztd�d	|f��WYdd}~XnXnZt|
tj	j��rvd
�k�rv|j�d
��d
<n,t|
tj	j��r�d�k�r�|j�d��d<|
}�jdd�}t�fdd��D��}
y|f|
�}WnLtk
�r"}z.dt|�k�r��|
jd�|
d<|f|
�}WYdd}~XnX|�r4|j|�|dk	�rN|jtj|��|�r`|j||�|�r�x"|j�D]\}}t|||��qpW|S)z&Configure a handler from a dictionary.r7NrzUnable to set formatter %r: %sr:r�z()r/r;rztarget not configured yetz#Unable to set target handler %r: %sZmailhostZaddressrcs g|]}t|�r|�|f�qSr)rk)r�r�)r�rrr��sz6DictConfigurator.configure_handler.<locals>.<listcomp>z'stream'�streamZstrm)r~rr�r�rhr�r�rAr
rrBrZHandler�updater�ZSMTPHandlerr�Z
SysLogHandlerr�r@r?r�r�r�r�)rur�Zconfig_copyr7r�r:r�r4r�r�rGZthr�r�rxr�rrvr)r�rr��sl





$



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.rzUnable to add handler %r: %sN)r\r�r�rh)rurTrrIr�rrr�add_handlers�s

zDictConfigurator.add_handlersFcCs�|jdd�}|dk	r$|jtj|��|s�x |jdd�D]}|j|�q8W|jdd�}|rf|j||�|jdd�}|r�|j||�dS)zU
        Perform configuration which is common to root and non-root loggers.
        r:Nrr�)r1r?r
r�rr[r�r�)rurTr�r�r:rIrr�rrr�common_logger_config�sz%DictConfigurator.common_logger_configcCs6tj|�}|j|||�|jdd�}|dk	r2||_dS)z.Configure a non-root logger from a dictionary.rNN)r
r^r�r1rN)rurr�r�rTrNrrrr�s

z!DictConfigurator.configure_loggercCstj�}|j|||�dS)z*Configure a root logger from a dictionary.N)r
r^r�)rur�r�rKrrrr�szDictConfigurator.configure_rootN)F)F)F)
rzr{r|r}r�r�r�r�r�r�r�r�r�rrrrr��s	?

r�cCst|�j�dS)z%Configure logging using a dictionary.N)�dictConfigClassr�)r�rrr�
dictConfig sr�csPtstd��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@seZdZdZdd�ZdS)z#listen.<locals>.ConfigStreamHandlerz�
        Handler for a logging configuration request.

        It expects a completely new logging configuration and uses fileConfig
        to install it.
        cSsH�y|j}|jd�}t|�dk�rtjd|�d}|jj|�}x&t|�|krd||j|t|��}q@W|jjdk	r~|jj|�}|dk	r�|jd�}yddl}|j	|�}t
|�WnHtk
r�tj
|�}yt|�Wntk
r�tj�YnXYnX|jj�r|jjj�Wn2tk
�rB}z|jtk�r2�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
connectionZrecvr0�struct�unpack�server�verify�decode�json�loadsr�r��io�StringIOr�	traceback�	print_exc�ready�set�OSError�errno�RESET_ERROR)ruZconn�chunkZslenr�r��filer�rrr�handleBs6




z*listen.<locals>.ConfigStreamHandler.handleN)rzr{r|r}r�rrrr�ConfigStreamHandler;sr�c@s0eZdZdZdZdedddfdd�Zdd�ZdS)	z$listen.<locals>.ConfigSocketReceiverzD
        A simple TCP socket-based logging config receiver.
        rXZ	localhostNcSs>tj|||f|�tj�d|_tj�d|_||_||_dS)NrrX)	rr�r
r�abortr�timeoutr�r�)ru�host�portr�r�r�rrrr�psz-listen.<locals>.ConfigSocketReceiver.__init__cSsfddl}d}xJ|sV|j|jj�ggg|j�\}}}|r>|j�tj�|j}tj�qW|jj	�dS)Nr)
�selectZsocket�filenor�Zhandle_requestr
rr�r�close)rur�r�Zrd�wrZexrrr�serve_until_stoppedzsz8listen.<locals>.ConfigSocketReceiver.serve_until_stopped)rzr{r|r}Zallow_reuse_address�DEFAULT_LOGGING_CONFIG_PORTr�r�rrrr�ConfigSocketReceiveris
	r�cs&eZdZ��fdd�Zdd�Z�ZS)zlisten.<locals>.Servercs4t�|�j�||_||_||_||_tj�|_dS)N)	�superr��rcvr�hdlrr�r��	threadingZEventr�)rur�r�r�r�)�Server�	__class__rrr��szlisten.<locals>.Server.__init__cSsZ|j|j|j|j|jd�}|jdkr0|jd|_|jj�tj�|a	tj
�|j�dS)N)r�r�r�r�rrX)r�r�r�r�r�Zserver_addressr�r
r�	_listenerrr�)rur�rrr�run�s


zlisten.<locals>.Server.run)rzr{r|r�r��
__classcell__r)r�)r�rr��sr�)�thread�NotImplementedErrorrrr�ZThread)r�r�r�r�r)r�r�listen%s.r�c
Cs*tj�ztrdt_daWdtj�XdS)zN
    Stop the listening server which was created with a call to listen().
    rXN)r
rr�r�rrrrr�
stopListening�sr�)NT).r}r�r�r
Zlogging.handlersr�r�r�r��_threadr�r�r�Zsocketserverrrr�Z
ECONNRESETr�r�rr!r&r	r
rUrrr��Irfrk�objectrlr~rprYrqr�rrr�r�r�r�r�r�rrrr�<module>sP

"#W!
9|

Zerion Mini Shell 1.0