ok

Mini Shell

Direktori : /proc/thread-self/root/opt/alt/python37/lib64/python3.7/logging/__pycache__/
Upload File :
Current File : //proc/thread-self/root/opt/alt/python37/lib64/python3.7/logging/__pycache__/config.cpython-37.pyc

B

� f���@sNdZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
mZmZdZ
ejZdad+dd�Zdd	�Zd
d�Zdd
�Zdd�Zdd�Zdd�Zdd�Ze�dej�Zdd�ZGdd�de�ZGdd�dee�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(e
dfd'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-2019 Vinay Sajip. All Rights Reserved.

To use, simply 'import logging' and log away!
�N)�ThreadingTCPServer�StreamRequestHandleriF#TcCs�ddl}t||j�r|}n*|�|�}t|d�r:|�|�n
|�|�t|�}t�	�z t
�t||�}t|||�Wdt�
�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)Zfname�defaults�disable_existing_loggersr�cp�
formatters�handlers�r�3/opt/alt/python37/lib64/python3.7/logging/config.py�
fileConfig3s	



rc	Csp|�d�}|�d�}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�_resolveUs


r"cCsttj|�S)N)�map�str�strip)Zalistrrr�
_strip_spacescsr&cCs�|dd}t|�siS|�d�}t|�}i}x~|D]v}d|}|j|dddd�}|j|d	ddd�}|j|d
ddd�}tj}||�d�}	|	r�t|	�}||||�}
|
||<q4W|S)
zCreate and return formattersr�keys�,zformatter_%s�formatTN)�raw�fallback�datefmt�style�%�class)�lenrr&�getr
�	Formatterr")rZflistrZformZsectnameZfsZdfsZstl�c�
class_name�frrrr	fs$

r	c
Csj|dd}t|�siS|�d�}t|�}i}g}�x|D�]}|d|}|d}|�dd�}yt|tt��}Wn ttfk
r�t	|�}YnX|�dd	�}	t|	tt��}	|�d
d�}
t|
tt��}
||	|
�}d|kr�|d}|�
|�t|��r|�||�t|tj
j��r8|�d
d�}
t|
��r8|�||
f�|||<q:Wx |D]\}}|�||��qJW|S)zInstall and return handlersrr'r(z
handler_%sr/�	formatter��argsz()�kwargsz{}�level�target)r0rr&r1�eval�varsr
r�	NameErrorr"�setLevel�setFormatter�
issubclassr�
MemoryHandler�appendZ	setTarget)rr�hlistrZfixups�hand�section�klass�fmtr8r9�hr:r;�trrrr
|sB




r
cCsXtj}xL|D]D}|jj|}||krJt|tj�sP|�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�
loggerDictrZPlaceHolderr?ZNOTSETr�	propagate�disabled)�existing�
child_loggers�disable_existingrK�log�loggerrrr�_handle_existing_loggers�s
rUcCs&|dd}|�d�}tt|��}|�d�|d}tj}|}d|krX|d}|�|�x |jdd�D]}|�|�qhW|d}	t	|	�r�|	�d�}	t|	�}	x|	D]}
|�
||
�q�Wt|jj�
��}|��g}�x>|D�]4}|d	|}|d
}
|jddd
�}t�|
�}|
|k�r�|�|
�d}|
d}t	|�}t	|�}x<||k�rz||d|�|k�rn|�||�|d7}�q@W|�|
�d|k�r�|d}|�|�x"|jdd�D]}|�|��q�W||_d|_|d}	t	|	�r�|	�d�}	t|	�}	x|	D]}
|�
||
��q�Wq�Wt|||�dS)zCreate and install loggers�loggersr'r(rKZlogger_rootr:Nrz	logger_%s�qualnamerN�)r+rr)r�listr&�remover
rKr?r�
removeHandlerr0�
addHandlerrLrMr'�sortZgetint�	getLogger�indexrCrNrOrU)rrrRZllistrFrKrSr:rIrDrErPrQZqnrNrT�i�prefixed�pflen�num_existingrrrr�sd











rcCs.tj��t�tjdd��tjdd�=dS)z!Clear and close existing handlersN)r
�	_handlers�clearZshutdownZ_handlerListrrrrrs
rz^[a-z_][a-z0-9_]*$cCst�|�}|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|j�|�}||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|j�|�}||k	r,t|�tttfkr,||_|S)N)rmrnrorprqrrrs)rurvrxrrrrn.s
zConvertingMixin.convertN)T)�__name__�
__module__�__qualname__�__doc__ryrnrrrrrls
rlc@s,eZdZdZdd�Zd	dd�Zd
dd�ZdS)rpz A converting dictionary wrapper.cCst�||�}|�||�S)N)�dict�__getitem__ry)rurtrvrrrrCszConvertingDict.__getitem__NcCst�|||�}|�||�S)N)r~r1ry)rurt�defaultrvrrrr1GszConvertingDict.getcCst�|||�}|j||dd�S)NF)rw)r~rry)rurtr�rvrrrrKszConvertingDict.pop)N)N)rzr{r|r}rr1rrrrrrp@s
rpc@s"eZdZdZdd�Zddd�ZdS)	rqzA converting list wrapper.cCst�||�}|�||�S)N)rYrry)rurtrvrrrrQszConvertingList.__getitem__���cCst�||�}|�|�S)N)rYrrn)ru�idxrvrrrrUszConvertingList.popN)r�)rzr{r|r}rrrrrrrqOsrqc@seZdZdZdd�ZdS)rrzA converting tuple wrapper.cCst�||�}|j||dd�S)NF)rw)�tuplerry)rurtrvrrrr[szConvertingTuple.__getitem__N)rzr{r|r}rrrrrrrYsrrc@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)�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__ts
zBaseConfigurator.__init__c		Cs�|�d�}|�d�}y`|�|�}xP|D]H}|d|7}yt||�}Wq&tk
rl|�|�t||�}Yq&Xq&W|Stk
r�t��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__)	rurirrr Zfrag�e�tb�vrrr�resolvexs"




zBaseConfigurator.resolvecCs
|�|�S)z*Default converter for the ext:// protocol.)r�)rurvrrrr��szBaseConfigurator.ext_convertcCs|}|j�|�}|dkr&td|��n�||��d�}|j|��d}x�|r�|j�|�}|rp||��d}nd|j�|�}|r�|��d}|j�|�s�||}n2yt	|�}||}Wnt
k
r�||}YnX|r�||��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�s$t|t�r$t|�}||_n�t|t�sHt|t�rHt|�}||_n�t|t�svt|t�rvt|d�svt|�}||_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.
        �_fields�prefixN�suffix)rrpr~rmrqrYrrr�rr$�CONVERT_PATTERNrg�	groupdict�value_convertersr1r)rurvrjr�r�Z	converterr�rrrrn�s*


zBaseConfigurator.convertcsn��d�}t|�s|�|�}��dd�}�fdd��D�}|f|�}|rjx |��D]\}}t|||�qRW|S)z1Configure an object with a user-supplied factory.z()rNcsi|]}t|�r�||�qSr)rk)�.0�k)r�rr�
<dictcomp>�sz5BaseConfigurator.configure_custom.<locals>.<dictcomp>)r�callabler��items�setattr)rur�r3�propsr9rxrrvr)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�`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��|�dd�}i}t���z�|�r�|�d|�}x�|D]�}|tjkr�td|��qfy6tj|}||}|�d	d
�}|r�|�t�|��Wqft	k
r�}	ztd|�|	�Wd
d
}	~	XYqfXqfW|�d|�}
xX|
D]P}y|�
||
|d
�Wn2t	k
�rL}	ztd|�|	�Wd
d
}	~	XYnX�qW|�dd
�}|�r�y|�|d
�Wn.t	k
�r�}	ztd�|	�Wd
d
}	~	XYnX�n0|�dd
�}t�|�d|�}
xX|
D]P}y|�
|
|�|
|<Wn2t	k
�r}	ztd|�|	�Wd
d
}	~	XYnX�q�W|�d|�}xX|D]P}y|�||�||<Wn2t	k
�r�}	ztd|�|	�Wd
d
}	~	XYnX�q4W|�d|�}g}x�t|�D]v}y |�||�}||_|||<WnNt	k
�r}	z.dt|	j�k�r�|�|�ntd|�|	�Wd
d
}	~	XYnX�q�Wxb|D]Z}y |�||�}||_|||<Wn2t	k
�rx}	ztd|�|	�Wd
d
}	~	XYnX�q"Wtj}t|jj���}|��g}|�d|�}
x�|
D]�}||k�r0|�|�d}|d}t|�}t|�}x<||k�r$||d
|�|k�r|�||�|d7}�q�W|�|�y|�
||
|�Wn2t	k
�rv}	ztd|�|	�Wd
d
}	~	XYnX�q�Wt|||�|�dd
�}|�r�y|�|�Wn.t	k
�r�}	ztd�|	�Wd
d
}	~	XYnXWd
t��Xd
S)zDo the configuration.�versionz$dictionary doesn't specify a versionrXzUnsupported version: %s�incrementalFrzNo handler found with name %rr:NzUnable to configure handler %rrVTzUnable to configure logger %rrKzUnable to configure root loggerrrz Unable to configure formatter %r�filterszUnable to configure filter %rztarget not configured yetr) r�rhrr
rr1rdr?�_checkLevel�	Exception�configure_logger�configure_rootr�configure_formatter�configure_filter�sorted�configure_handlerrr$r�rCrKrYrLrMr'r]r_r0rZrUr)rur�r�Z
EMPTY_DICTrr�handlerZhandler_configr:r�rVrKrRrr�ZdeferredrPrQr`rarbrcrrr�	configure�s�



 
"
"
""
"


"zDictConfigurator.configurec

Cs�d|krr|d}y|�|�}Wq�tk
rn}z2dt|�kr>�|�d�|d<||d<|�|�}Wdd}~XYq�XnP|�dd�}|�dd�}|�dd�}|�d	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-�cnamer3rrrr��s&z$DictConfigurator.configure_formattercCs.d|kr|�|�}n|�dd�}t�|�}|S)z%Configure a filter from a dictionary.z()rr7)r�r1r
ZFilter)rur�rxrrrrr��s

z!DictConfigurator.configure_filtercCs\xV|D]N}y|�|jd|�Wqtk
rR}ztd|�|�Wdd}~XYqXqWdS)z/Add filters to a filterer from a list of names.r�zUnable to add filter %rN)Z	addFilterr�r�rh)ruZfiltererr�r5r�rrr�add_filters�s

zDictConfigurator.add_filtersc
s�t��}��dd�}|r\y|jd|}Wn0tk
rZ}ztd|�|�Wdd}~XYnX��dd�}��dd�}d�kr���d�}t|�s�|�|�}|}�n��d�}	|�|	�}
t|
tj	j
��rFd	�k�rFy>|jd
�d	}t|tj��s��
|�td��|�d	<Wn6tk
�rB}ztd�d	�|�Wdd}~XYnXnZt|
tj	j��rtd
�k�rt|��d
��d
<n,t|
tj	j��r�d�k�r�|��d��d<|
}��dd�}�fdd��D�}
y|f|
�}WnLtk
�r}z,dt|�k�r�|
�d�|
d<|f|
�}Wdd}~XYnX|�r.|�|�|dk	�rH|�t�|��|�rZ|�||�|�r�x"|��D]\}}t|||��qjW|S)z&Configure a handler from a dictionary.r6NrzUnable to set formatter %rr:r�z()r/r;rztarget not configured yetzUnable to set target handler %rZmailhostZaddressrcsi|]}t|�r�||�qSr)rk)r�r�)r�rrr��sz6DictConfigurator.configure_handler.<locals>.<dictcomp>z'stream'�streamZstrm)r~rr�r�rhr�r�rAr
rrBrZHandler�updater�ZSMTPHandlerr�Z
SysLogHandlerr$r@r?r�r�r�r�)rur�Zconfig_copyr6r�r:r�r3r�r�rGZthr�r9rxr�rrvr)r�rr��sl





"



z"DictConfigurator.configure_handlercCs\xV|D]N}y|�|jd|�Wqtk
rR}ztd|�|�Wdd}~XYqXqWdS)z.Add handlers to a logger from a list of names.rzUnable to add handler %rN)r\r�r�rh)rurTrrIr�rrr�add_handlers�s

zDictConfigurator.add_handlersFcCs�|�dd�}|dk	r$|�t�|��|s�x |jdd�D]}|�|�q8W|�dd�}|rf|�||�|�dd�}|r�|�||�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_configcCs6t�|�}|�|||�|�dd�}|dk	r2||_dS)z.Configure a non-root logger from a dictionary.rNN)r
r^r�r1rN)rurr�r�rTrNrrrr�s

z!DictConfigurator.configure_loggercCst��}|�|||�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|���dS)z%Configure logging using a dictionary.N)�dictConfigClassr�)r�rrr�
dictConfigsr�csDGdd�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.
    c@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.
        cSs\�y"|j}|�d�}t|�dk�r"t�d|�d}|j�|�}x&t|�|krd||�|t|��}q@W|jjdk	r~|j�|�}|dk	�r|�d�}y,ddl}|�	|�}t
|t�s�t�t
|�WnLtk
�r
t�|�}yt|�Wntk
�rt��YnXYnX|jj�r"|jj��Wn2tk
�rV}z|jtk�rF�Wdd}~XYnXdS)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�structZunpack�server�verify�decode�json�loadsrr~�AssertionErrorr�r��io�StringIOr�	traceback�	print_exc�ready�set�OSError�errno�RESET_ERROR)ruZconn�chunkZslenr�r��filer�rrr�handle>s8





z*listen.<locals>.ConfigStreamHandler.handleN)rzr{r|r}r�rrrr�ConfigStreamHandler7sr�c@s0eZdZdZdZdedddfdd�Zdd�ZdS)	z$listen.<locals>.ConfigSocketReceiverzD
        A simple TCP socket-based logging config receiver.
        rXZ	localhostNcSs>t�|||f|�t��d|_t��d|_||_||_dS)NrrX)	rr�r
r�abortr�timeoutr�r�)ruZhost�portr�r�r�rrrr�lsz-listen.<locals>.ConfigSocketReceiver.__init__cSsdddl}d}xJ|sV|�|j��ggg|j�\}}}|r>|��t��|j}t��qW|�	�dS)Nr)
�selectZsocket�filenor�Zhandle_requestr
rr�rZserver_close)rur�r�ZrdZwrZexrrr�serve_until_stoppedvsz8listen.<locals>.ConfigSocketReceiver.serve_until_stopped)rzr{r|r}Zallow_reuse_address�DEFAULT_LOGGING_CONFIG_PORTr�r�rrrr�ConfigSocketReceiveres
	r�cs&eZdZ��fdd�Zdd�Z�ZS)zlisten.<locals>.Servercs4t�|���||_||_||_||_t��|_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|_|j��t��|a	t�
�|��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�)rrr�ZThread)r�r�r�r�r)r�r�listen#s.r�cCs*t��ztrdt_daWdt��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�r�Zsocketserverrrr�Z
ECONNRESETr�r�rr"r&r	r
rUrrr��Irfrk�objectrlr~rprYrqr�rrr�r�r�r�r�r�rrrr�<module>sH
"%W!
9z

Zerion Mini Shell 1.0