• File: config.cpython-37.opt-1.pyc
  • Full Path: /home3/farmfre2/public_html/ALFA_DATA/alfasymlink/root/opt/alt/python37/lib64/python3.7/logging/__pycache__/config.cpython-37.opt-1.pyc
  • Date Modified: 10/26/2026 8:08 PM
  • File size: 22.48 KB
  • MIME-type: text/x-bytecode.python
  • Charset: 8 bit
B

Sj@sNdZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
mZmZdZ
ejZdad+ddZdd	Zd
dZdd
ZddZddZddZddZedejZddZGdddeZGdddeeZ Gddde!eZ"Gdd d e#eZ$Gd!d"d"eZ%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)ThreadingTCPServerStreamRequestHandleriF#TcCsddl}t||jr|}n*||}t|dr:||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).
    rNreadline)configparser
isinstanceZRawConfigParserZConfigParserhasattrZ	read_fileread_create_formatterslogging_acquireLock_clearExistingHandlers_install_handlers_install_loggers_releaseLock)Zfnamedefaultsdisable_existing_loggersrcp
formattershandlersr3/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)splitpop
__import__getattrAttributeError)nameusedfoundnrrr_resolveUs


r"cCsttj|S)N)mapstrstrip)Zalistrrr
_strip_spacescsr&cCs|dd}t|siS|d}t|}i}x~|D]v}d|}|j|dddd}|j|d	ddd}|j|d
ddd}tj}||d}	|	rt|	}||||}
|
||<q4W|S)
zCreate and return formattersrkeys,zformatter_%sformatTN)rawfallbackdatefmtstyle%class)lenrr&getr
	Formatterr")rZflistrZformZsectnameZfsZdfsZstlc
class_namefrrrr	fs$

r	c
Csj|dd}t|siS|d}t|}i}g}x|D]}|d|}|d}|dd}yt|tt}Wn ttfk
rt	|}YnX|dd	}	t|	tt}	|d
d}
t|
tt}
||	|
}d|kr|d}|
|t|r|||t|tj
jr8|d
d}
t|
r8|||
f|||<q:Wx |D]\}}|||qJW|S)zInstall and return handlersrr'r(z
handler_%sr/	formatterargsz()kwargsz{}leveltarget)r0rr&r1evalvarsr
r	NameErrorr"setLevelsetFormatter
issubclassr
MemoryHandlerappendZ	setTarget)rrhlistrZfixupshandsectionklassfmtr8r9hr:r;trrrr
|sB




r
cCsXtj}xL|D]D}|jj|}||krJt|tjsP|tjg|_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
rootmanager
loggerDictrZPlaceHolderr?ZNOTSETr	propagatedisabled)existing
child_loggersdisable_existingrKlogloggerrrr_handle_existing_loggerss
rUcCs&|dd}|d}tt|}|d|d}tj}|}d|krX|d}||x |jddD]}||qhW|d}	t	|	r|	d}	t|	}	x|	D]}
|
||
qWt|jj
}|g}x>|D]4}|d	|}|d
}
|jddd
}t|
}|
|kr||
d}|
d}t	|}t	|}x<||krz||d||krn||||d7}q@W||
d|kr|d}||x"|jddD]}||qW||_d|_|d}	t	|	r|	d}	t|	}	x|	D]}
|
||
qWqWt|||dS)zCreate and install loggersloggersr'r(rKZlogger_rootr:Nrz	logger_%squalnamerN)r+rr)rlistr&remover
rKr?r
removeHandlerr0
addHandlerrLrMr'sortZgetint	getLoggerindexrCrNrOrU)rrrRZllistrFrKrSr:rIrDrErPrQZqnrNrTiprefixedpflennum_existingrrrrsd











rcCs.tjttjddtjdd=dS)z!Clear and close existing handlersN)r
	_handlersclearZshutdownZ_handlerListrrrrrs
rz^[a-z_][a-z0-9_]*$cCst|}|std|dS)Nz!Not a valid Python identifier: %rT)
IDENTIFIERmatch
ValueError)smrrrvalid_idents
rkc@s"eZdZdZdddZddZdS)	ConvertingMixinz?For ConvertingXXX's, this mixin class provides common functionsTcCsB|j|}||k	r>|r |||<t|tttfkr>||_||_|S)N)configuratorconverttypeConvertingDictConvertingListConvertingTupleparentkey)selfrtvaluereplaceresultrrrconvert_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,eZdZdZddZd	ddZd
ddZdS)rpz A converting dictionary wrapper.cCst||}|||S)N)dict__getitem__ry)rurtrvrrrrCszConvertingDict.__getitem__NcCst|||}|||S)N)r~r1ry)rurtdefaultrvrrrr1GszConvertingDict.getcCst|||}|j||ddS)NF)rw)r~rry)rurtrrvrrrrKszConvertingDict.pop)N)N)rzr{r|r}rr1rrrrrrp@s
rpc@s"eZdZdZddZdddZdS)	rqzA converting list wrapper.cCst||}|||S)N)rYrry)rurtrvrrrrQszConvertingList.__getitem__cCst||}||S)N)rYrrn)ruidxrvrrrrUszConvertingList.popN)r)rzr{r|r}rrrrrrrqOsrqc@seZdZdZddZdS)rrzA converting tuple wrapper.cCst||}|j||ddS)NF)rw)tuplerry)rurtrvrrrr[szConvertingTuple.__getitem__N)rzr{r|r}rrrrrrrYsrrc@seZdZdZedZedZedZedZ	edZ
ddd	Zee
Zd
dZdd
ZddZddZddZddZddZdS)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_convertcfg_convert)ZextZcfgcCst||_||j_dS)N)rpconfigrm)rurrrr__init__ts
zBaseConfigurator.__init__c		Cs|d}|d}y`||}xP|D]H}|d|7}yt||}Wq&tk
rl||t||}Yq&Xq&W|Stk
rtdd\}}td||f}|||_	|_
|YnXdS)z`
        Resolve strings to objects using standard import and attribute
        syntax.
        rrrXNzCannot resolve %r: %s)rrimporterrrImportErrorsysexc_inforh	__cause__
__traceback__)	rurirrr Zfragetbvrrrresolvexs"




zBaseConfigurator.resolvecCs
||S)z*Default converter for the ext:// protocol.)r)rurvrrrrszBaseConfigurator.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||fqJW|S)z*Default converter for the cfg:// protocol.NzUnable to convert %rrzUnable to convert %r at %r)WORD_PATTERNrgrhendrgroupsDOT_PATTERN
INDEX_PATTERN
DIGIT_PATTERNint	TypeError)rurvrestrjdrr!rrrrs2
zBaseConfigurator.cfg_convertcCst|ts$t|tr$t|}||_nt|tsHt|trHt|}||_nt|tsvt|trvt|dsvt|}||_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.
        _fieldsprefixNsuffix)rrpr~rmrqrYrrrrr$CONVERT_PATTERNrg	groupdictvalue_convertersr1r)rurvrjrrZ	converterrrrrrns*


zBaseConfigurator.convertcsnd}t|s||}dd}fddD}|f|}|rjx |D]\}}t|||qRW|S)z1Configure an object with a user-supplied factory.z()rNcsi|]}t|r||qSr)rk).0k)rrr
<dictcomp>sz5BaseConfigurator.configure_custom.<locals>.<dictcomp>)rcallableritemssetattr)rurr3propsr9rxrrvr)rrconfigure_customs


z!BaseConfigurator.configure_customcCst|trt|}|S)z0Utility function which converts lists to tuples.)rrYr)rurvrrras_tuples
zBaseConfigurator.as_tupleN)rzr{r|r}recompilerrrrrrstaticmethodrrrrrrrnrrrrrrr`s 




"rc@s^eZdZdZddZddZddZdd	Zd
dZdd
Z	dddZ
dddZdddZdS)DictConfiguratorz]
    Configure logging using a dictionary-like object to describe the
    configuration.
    cCs|j}d|krtd|ddkr2td|d|dd}i}tz|r|d|}x|D]}|tjkrtd|qfy6tj|}||}|d	d
}|r|t|Wqft	k
r}	ztd||	Wd
d
}	~	XYqfXqfW|d|}
xX|
D]P}y|
||
|d
Wn2t	k
rL}	ztd||	Wd
d
}	~	XYnXqW|dd
}|ry||d
Wn.t	k
r}	ztd|	Wd
d
}	~	XYnXn0|dd
}t|d|}
xX|
D]P}y|
|
||
|<Wn2t	k
r}	ztd||	Wd
d
}	~	XYnXqW|d|}xX|D]P}y|||||<Wn2t	k
r}	ztd||	Wd
d
}	~	XYnXq4W|d|}g}xt|D]v}y |||}||_|||<WnNt	k
r}	z.dt|	jkr||ntd||	Wd
d
}	~	XYnXqWxb|D]Z}y |||}||_|||<Wn2t	k
rx}	ztd||	Wd
d
}	~	XYnXq"Wtj}t|jj}|g}|d|}
x|
D]}||kr0||d}|d}t|}t|}x<||kr$||d
||kr||||d7}qW||y|
||
|Wn2t	k
rv}	ztd||	Wd
d
}	~	XYnXqWt||||dd
}|ry||Wn.t	k
r}	ztd|	Wd
d
}	~	XYnXWd
tXd
S)zDo the configuration.versionz$dictionary doesn't specify a versionrXzUnsupported version: %sincrementalFrzNo handler found with name %rr:NzUnable to configure handler %rrVTzUnable to configure logger %rrKzUnable to configure root loggerrrz Unable to configure formatter %rfilterszUnable to configure filter %rztarget not configured yetr) rrhrr
rr1rdr?_checkLevel	Exceptionconfigure_loggerconfigure_rootrconfigure_formatterconfigure_filtersortedconfigure_handlerrr$rrCrKrYrLrMr'r]r_r0rZrUr)rurrZ
EMPTY_DICTrrhandlerZhandler_configr:rrVrKrRrrZdeferredrPrQr`rarbrcrrr	configures



 
"
"
""
"


"zDictConfigurator.configurec

Csd|krr|d}y||}Wqtk
rn}z2dt|kr>|d|d<||d<||}Wdd}~XYqXnP|dd}|dd}|dd}|d	d}|stj}	nt|}	|	|||}|S)
z(Configure a formatter from a dictionary.z()z'format'r)rHNr,r-r.r/)rrr$rr1r
r2r")
rurfactoryrxterHZdfmtr-cnamer3rrrrs&z$DictConfigurator.configure_formattercCs.d|kr||}n|dd}t|}|S)z%Configure a filter from a dictionary.z()rr7)rr1r
ZFilter)rurrxrrrrrs

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.rzUnable to add filter %rN)Z	addFilterrrrh)ruZfiltererrr5rrrradd_filterss

zDictConfigurator.add_filtersc
st}dd}|r\y|jd|}Wn0tk
rZ}ztd||Wdd}~XYnXdd}dd}dkrd}t|s||}|}nd}	||	}
t|
tj	j
rFd	krFy>|jd
d	}t|tjs
|td|d	<Wn6tk
rB}ztdd	|Wdd}~XYnXnZt|
tj	jrtd
krt|d
d
<n,t|
tj	jrdkr|dd<|
}dd}fddD}
y|f|
}WnLtk
r}z,dt|kr|
d|
d<|f|
}Wdd}~XYnX|r.|||dk	rH|t||rZ||||rx"|D]\}}t|||qjW|S)z&Configure a handler from a dictionary.r6NrzUnable to set formatter %rr:rz()r/r;rztarget not configured yetzUnable to set target handler %rZmailhostZaddressrcsi|]}t|r||qSr)rk)rr)rrrrsz6DictConfigurator.configure_handler.<locals>.<dictcomp>z'stream'streamZstrm)r~rrrrhrrrAr
rrBrZHandlerupdaterZSMTPHandlerrZ
SysLogHandlerr$r@r?rrrr)rurZconfig_copyr6rr:rr3rrrGZthrr9rxrrrvr)rrrsl





"



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\rrrh)rurTrrIrrrradd_handlerss

zDictConfigurator.add_handlersFcCs|dd}|dk	r$|t||sx |jddD]}||q8W|dd}|rf||||dd}|r|||dS)zU
        Perform configuration which is common to root and non-root loggers.
        r:Nrr)r1r?r
rrr[rr)rurTrrr:rIrrrrrcommon_logger_configsz%DictConfigurator.common_logger_configcCs6t|}|||||dd}|dk	r2||_dS)z.Configure a non-root logger from a dictionary.rNN)r
r^rr1rN)rurrrrTrNrrrrs

z!DictConfigurator.configure_loggercCst}||||dS)z*Configure a root logger from a dictionary.N)r
r^r)rurrrKrrrrszDictConfigurator.configure_rootN)F)F)F)
rzr{r|r}rrrrrrrrrrrrrrs	?

rcCst|dS)z%Configure logging using a dictionary.N)dictConfigClassr)rrrr
dictConfigsrcsDGdddt}Gdddt}Gfdddtj||||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@seZdZdZddZdS)z#listen.<locals>.ConfigStreamHandlerz
        Handler for a logging configuration request.

        It expects a completely new logging configuration and uses fileConfig
        to install it.
        cSsHy|j}|d}t|dkrtd|d}|j|}x&t||krd|||t|}q@W|jjdk	r~|j|}|dk	r|d}yddl}|	|}t
|WnHtk
rt
|}yt|Wntk
rtYnXYnX|jjr|jjWn2tk
rB}z|jtkr2Wdd}~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
connectionZrecvr0structZunpackserververifydecodejsonloadsrrioStringIOr	traceback	print_excreadysetOSErrorerrnoRESET_ERROR)ruZconnchunkZslenrrfilerrrrhandle>s6




z*listen.<locals>.ConfigStreamHandler.handleN)rzr{r|r}rrrrrConfigStreamHandler7src@s0eZdZdZdZdedddfddZddZdS)	z$listen.<locals>.ConfigSocketReceiverzD
        A simple TCP socket-based logging config receiver.
        rXZ	localhostNcSs>t|||f|td|_td|_||_||_dS)NrrX)	rrr
rabortrtimeoutrr)ruZhostportrrrrrrrlsz-listen.<locals>.ConfigSocketReceiver.__init__cSsdddl}d}xJ|sV||jggg|j\}}}|r>|t|j}tqW|	dS)Nr)
selectZsocketfilenorZhandle_requestr
rrrZserver_close)rurrZrdZwrZexrrrserve_until_stoppedvsz8listen.<locals>.ConfigSocketReceiver.serve_until_stopped)rzr{r|r}Zallow_reuse_addressDEFAULT_LOGGING_CONFIG_PORTrrrrrrConfigSocketReceiveres
	rcs&eZdZfddZddZZS)zlisten.<locals>.Servercs4t|||_||_||_||_t|_dS)N)	superrrcvrhdlrrr	threadingZEventr)rurrrr)Server	__class__rrrszlisten.<locals>.Server.__init__cSsZ|j|j|j|j|jd}|jdkr0|jd|_|jt|a	t
|dS)N)rrrrrrX)rrrrrZserver_addressrr
r	_listenerrr)rurrrrruns


zlisten.<locals>.Server.run)rzr{r|rr
__classcell__r)r)rrrsr)rrrZThread)rrrrr)rrlisten#s.rcCs*tztrdt_daWdtXdS)zN
    Stop the listening server which was created with a call to listen().
    rXN)r
rrrrrrrr
stopListeningsr)NT)+r}rrr
Zlogging.handlersrrrrrZsocketserverrrrZ
ECONNRESETrrrr"r&r	r
rUrrrIrfrkobjectrlr~rprYrqrrrrrrrrrrrrr<module>sH
"%W!
9z