Your IP : 3.17.76.163


Current Path : /lib/python2.7/site-packages/pip/compat/
Upload File :
Current File : //lib/python2.7/site-packages/pip/compat/dictconfig.pyc

�
��abc@@s ddlmZddlZddlZddlZddlZddlmZej	dej
�Zd�Zyddlm
Z
Wnek
r�d�Z
nXdefd	��YZd
efd��YZdefd
��YZdefd��YZdefd��YZeZd�ZdS(i(tabsolute_importN(tsixs^[a-z_][a-z0-9_]*$cC@s,tj|�}|s(td|��ntS(Ns!Not a valid Python identifier: %r(t
IDENTIFIERtmatcht
ValueErrortTrue(tstm((s9/usr/lib/python2.7/site-packages/pip/compat/dictconfig.pytvalid_ident"s(t_checkLevelcC@spt|t�r|}nTt|�|kr\|tjkrLtd|��ntj|}ntd|��|S(NsUnknown level: %rs*Level not an integer or a valid string: %r(t
isinstancetinttstrtloggingt_levelNamesRt	TypeError(tleveltrv((s9/usr/lib/python2.7/site-packages/pip/compat/dictconfig.pyR	.s	
tConvertingDictcB@s/eZdZd�Zdd�Zdd�ZRS(s A converting dictionary wrapper.cC@sqtj||�}|jj|�}||k	rm|||<t|�tttfkrm||_||_	qmn|S(N(
tdictt__getitem__tconfiguratortconvertttypeRtConvertingListtConvertingTupletparenttkey(tselfRtvaluetresult((s9/usr/lib/python2.7/site-packages/pip/compat/dictconfig.pyRGs
	cC@sttj|||�}|jj|�}||k	rp|||<t|�tttfkrp||_||_	qpn|S(N(
RtgetRRRRRRRR(RRtdefaultRR((s9/usr/lib/python2.7/site-packages/pip/compat/dictconfig.pyRSs
	cC@sjtj|||�}|jj|�}||k	rft|�tttfkrf||_||_	qfn|S(N(
RtpopRRRRRRRR(RRR RR((s9/usr/lib/python2.7/site-packages/pip/compat/dictconfig.pyR!_s	N(t__name__t
__module__t__doc__RtNoneRR!(((s9/usr/lib/python2.7/site-packages/pip/compat/dictconfig.pyRDs	RcB@s#eZdZd�Zdd�ZRS(sA converting list wrapper.cC@sqtj||�}|jj|�}||k	rm|||<t|�tttfkrm||_||_	qmn|S(N(
tlistRRRRRRRRR(RRRR((s9/usr/lib/python2.7/site-packages/pip/compat/dictconfig.pyRls
	i����cC@s^tj||�}|jj|�}||k	rZt|�tttfkrZ||_qZn|S(N(	R&R!RRRRRRR(RtidxRR((s9/usr/lib/python2.7/site-packages/pip/compat/dictconfig.pyR!xs(R"R#R$RR!(((s9/usr/lib/python2.7/site-packages/pip/compat/dictconfig.pyRjs	RcB@seZdZd�ZRS(sA converting tuple wrapper.cC@sgtj||�}|jj|�}||k	rct|�tttfkrc||_||_	qcn|S(N(
ttupleRRRRRRRRR(RRRR((s9/usr/lib/python2.7/site-packages/pip/compat/dictconfig.pyR�s	(R"R#R$R(((s9/usr/lib/python2.7/site-packages/pip/compat/dictconfig.pyR�stBaseConfiguratorcB@s�eZdZejd�Zejd�Zejd�Zejd�Zejd�Z	idd6dd	6Z
eZd
�Z
d�Zd�Zd
�Zd�Zd�Zd�ZRS(sI
    The configurator base class which defines some useful defaults.
    s%^(?P<prefix>[a-z]+)://(?P<suffix>.*)$s^\s*(\w+)\s*s^\.\s*(\w+)\s*s^\[\s*(\w+)\s*\]\s*s^\d+$text_converttexttcfg_converttcfgcC@st|�|_||j_dS(N(RtconfigR(RR.((s9/usr/lib/python2.7/site-packages/pip/compat/dictconfig.pyt__init__�sc	C@s�|jd�}|jd�}yy|j|�}x_|D]W}|d|7}yt||�}Wq7tk
r�|j|�t||�}q7Xq7W|SWnVtk
r�tj�d\}}td||f�}|||_	|_
|�nXdS(s`
        Resolve strings to objects using standard import and attribute
        syntax.
        t.iisCannot resolve %r: %sN(tsplitR!timportertgetattrtAttributeErrortImportErrortsystexc_infoRt	__cause__t
__traceback__(	RRtnametusedtfoundtfragtettbtv((s9/usr/lib/python2.7/site-packages/pip/compat/dictconfig.pytresolve�s"



cC@s
|j|�S(s*Default converter for the ext:// protocol.(RA(RR((s9/usr/lib/python2.7/site-packages/pip/compat/dictconfig.pyR*�scC@sO|}|jj|�}|dkr7td|��n||j�}|j|j�d}x�|rJ|jj|�}|r�||j�d}n�|jj|�}|r|j�d}|j	j|�s�||}qyt
|�}||}Wqtk
r||}qXn|r1||j�}qatd||f��qaW|S(s*Default converter for the cfg:// protocol.sUnable to convert %risUnable to convert %r at %rN(tWORD_PATTERNRR%RtendR.tgroupstDOT_PATTERNt
INDEX_PATTERNt
DIGIT_PATTERNRR(RRtrestRtdR'tn((s9/usr/lib/python2.7/site-packages/pip/compat/dictconfig.pyR,�s2	

cC@s2t|t�r7t|t�r7t|�}||_n�t|t�rnt|t�rnt|�}||_n�t|t�r�t|t�r�t|�}||_n�t|tj	�r.|j
j|�}|r.|j�}|d}|j
j|d�}|r+|d}t||�}||�}q+q.n|S(s�
        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.
        tprefixtsuffixN(R
RRRRR&RR(Rtstring_typestCONVERT_PATTERNRt	groupdicttvalue_convertersRR%R3(RRRRIRKt	converterRL((s9/usr/lib/python2.7/site-packages/pip/compat/dictconfig.pyR�s*

c@s��jd�}t|d�rUttd�rUt|�tjkrU|j|�}n�jdd�}t�fd��D��}||�}|r�x-|j�D]\}}t	|||�q�Wn|S(s1Configure an object with a user-supplied factory.s()t__call__t	ClassTypeR0c3@s+|]!}t|�r|�|fVqdS(N(R(t.0tk(R.(s9/usr/lib/python2.7/site-packages/pip/compat/dictconfig.pys	<genexpr>sN(
R!thasattrttypesRRSRAR%Rtitemstsetattr(RR.tctpropstkwargsRR:R((R.s9/usr/lib/python2.7/site-packages/pip/compat/dictconfig.pytconfigure_customs4cC@s"t|t�rt|�}n|S(s0Utility function which converts lists to tuples.(R
R&R((RR((s9/usr/lib/python2.7/site-packages/pip/compat/dictconfig.pytas_tuples(R"R#R$tretcompileRNRBRERFRGRPt
__import__R2R/RAR*R,RR]R^(((s9/usr/lib/python2.7/site-packages/pip/compat/dictconfig.pyR)�s"
				"		tDictConfiguratorcB@sheZdZd�Zd�Zd�Zd�Zd�Zd�Ze	d�Z
e	d�Ze	d	�ZRS(
s]
    Configure logging using a dictionary-like object to describe the
    configuration.
    cC@sq|j}d|kr$td��n|ddkrKtd|d��n|jdt�}i}tj�z�|r|jd|�}tjd dkrFx�|D]�}|tj	kr�td	|��q�yItj	|}||}|jd
d�}|r|jt|��nWq�t
k
r>}	td||	f��q�Xq�Wn|jd|�}
xU|
D]M}y|j||
|t�Wq_t
k
r�}	td
||	f��q_Xq_W|jdd�}|r^y|j|t�Wqt
k
r}	td|	��qXq^nV|jdt�}tj	j�tj2|jd|�}
xU|
D]M}y|j|
|�|
|<WqGt
k
r�}	td||	f��qGXqGW|jd|�}xU|D]M}y|j||�||<Wq�t
k
r�}	td||	f��q�Xq�W|jd|�}xjt|�D]\}y*|j||�}||_|||<Wq!t
k
r|}	td||	f��q!Xq!Wtj}t|jj�}|j�g}|jd|�}
x�|
D]�}||krd|j|�}|d}t|�}t|�}|d}x?||krS||| |krS|j||�|d}qW|j |�ny|j||
|�Wq�t
k
r�}	td
||	f��q�Xq�Wx]|D]U}|jj|}||kr�tj!|_"g|_#t|_$q�|r�t|_%q�q�W|jdd�}|r^y|j|�Wq^t
k
rZ}	td|	��q^XnWdtj&�XdS(sDo the configuration.tversions$dictionary doesn't specify a versionisUnsupported version: %stincrementalthandlersiisNo handler found with name %rRs"Unable to configure handler %r: %stloggerss!Unable to configure logger %r: %stroots#Unable to configure root logger: %stdisable_existing_loggerst
formatterss$Unable to configure formatter %r: %stfilterss!Unable to configure filter %r: %sR0N(ii('R.RR!tFalseR
t_acquireLockRR6tversion_infot	_handlersR%tsetLevelR	t
StandardErrortconfigure_loggerRtconfigure_roottcleart_handlerListtconfigure_formattertconfigure_filtertsortedtconfigure_handlerR:RgR&tmanagert
loggerDicttsorttindextlentappendtremovetNOTSETRRet	propagatetdisabledt_releaseLock(RR.Rdt
EMPTY_DICTReR:thandlerthandler_configRR>RfRgtdisable_existingRiRjtexistingt
child_loggerstitprefixedtpflentnum_existingtlogtlogger((s9/usr/lib/python2.7/site-packages/pip/compat/dictconfig.pyt	configures�	








		




	cC@s�d|kr�|d}y|j|�}Wq�tk
r�}dt|�krS�n|jd�|d<||d<|j|�}q�Xn6|jdd�}|jdd�}tj||�}|S(s(Configure a formatter from a dictionary.s()s'format'tformattfmttdatefmtN(R]RRR!RR%R
t	Formatter(RR.tfactoryRtteR�tdfmt((s9/usr/lib/python2.7/site-packages/pip/compat/dictconfig.pyRu�s

cC@sCd|kr|j|�}n!|jdd�}tj|�}|S(s%Configure a filter from a dictionary.s()R:t(R]RR
tFilter(RR.RR:((s9/usr/lib/python2.7/site-packages/pip/compat/dictconfig.pyRv�s
cC@s]xV|D]N}y|j|jd|�Wqtk
rT}td||f��qXqWdS(s/Add filters to a filterer from a list of names.RjsUnable to add filter %r: %sN(t	addFilterR.RpR(RtfiltererRjtfR>((s9/usr/lib/python2.7/site-packages/pip/compat/dictconfig.pytadd_filters�s

c@s��jdd�}|r\y|jd|}Wq\tk
rX}td||f��q\Xn�jdd�}�jdd�}d�kr��jd�}t|d�r�ttd�r�t|�tjkr�|j	|�}n|}n|j	�jd	��}t
|tjj
�rsd
�krsy|jd�d
�d
<Wq�tk
ro}td�d
|f��q�Xnvt
|tjj�r�d
�kr�|j�d
��d
<n;t
|tjj�r�d�kr�|j�d��d<n|}t�fd��D��}	y||	�}
WnJtk
rg}dt|�krE�n|	jd�|	d<||	�}
nX|r~|
j|�n|dk	r�|
jt|��n|r�|j|
|�n|
S(s&Configure a handler from a dictionary.t	formatterRisUnable to set formatter %r: %sRRjs()RRRStclassttargetRes#Unable to set target handler %r: %stmailhosttaddressc3@s+|]!}t|�r|�|fVqdS(N(R(RTRU(R.(s9/usr/lib/python2.7/site-packages/pip/compat/dictconfig.pys	<genexpr>�ss'stream'tstreamtstrmN(R!R%R.RpRRVRWRRSRAt
issubclassR
Ret
MemoryHandlertSMTPHandlerR^t
SysLogHandlerRRRtsetFormatterRoR	R�(RR.R�R>RRjRZR�tklassR\RR�((R.s9/usr/lib/python2.7/site-packages/pip/compat/dictconfig.pyRx�sX4	cC@s]xV|D]N}y|j|jd|�Wqtk
rT}td||f��qXqWdS(s.Add handlers to a logger from a list of names.ResUnable to add handler %r: %sN(t
addHandlerR.RpR(RR�RethR>((s9/usr/lib/python2.7/site-packages/pip/compat/dictconfig.pytadd_handlers	s

cC@s�|jdd�}|dk	r4|jt|��n|s�x|jD]}|j|�qEW|jdd�}|r�|j||�n|jdd�}|r�|j||�q�ndS(sU
        Perform configuration which is common to root and non-root loggers.
        RReRjN(RR%RoR	Ret
removeHandlerR�R�(RR�R.RdRR�ReRj((s9/usr/lib/python2.7/site-packages/pip/compat/dictconfig.pytcommon_logger_configscC@sPtj|�}|j|||�|jdd�}|dk	rL||_ndS(s.Configure a non-root logger from a dictionary.R�N(R
t	getLoggerR�RR%R�(RR:R.RdR�R�((s9/usr/lib/python2.7/site-packages/pip/compat/dictconfig.pyRq#s
cC@s#tj�}|j|||�dS(s*Configure a root logger from a dictionary.N(R
R�R�(RR.RdRg((s9/usr/lib/python2.7/site-packages/pip/compat/dictconfig.pyRr+s(
R"R#R$R�RuRvR�RxR�RkR�RqRr(((s9/usr/lib/python2.7/site-packages/pip/compat/dictconfig.pyRbs	�					5	cC@st|�j�dS(s%Configure logging using a dictionary.N(tdictConfigClassR�(R.((s9/usr/lib/python2.7/site-packages/pip/compat/dictconfig.pyt
dictConfig3s(t
__future__Rtlogging.handlersR
R_R6RWtpip._vendorRR`tIRRR	R5RRR&RR(RtobjectR)RbR�R�(((s9/usr/lib/python2.7/site-packages/pip/compat/dictconfig.pyt<module>s&		

&
��

?>