usr/lib/python2.7/site-packages/pip/compat/dictconfig.pyo000064400000040437147205400360017341 0ustar00 abc@@s ddlmZddlZddlZddlZddlZddlmZej dej Z dZ yddlm Z Wnek rdZ nXdefd YZd efd YZd efd YZdefdYZdefdYZeZdZdS(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.pyt valid_ident"s(t _checkLevelcC@spt|tr|}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/eZdZdZddZddZRS(s A converting dictionary wrapper.cC@sqtj||}|jj|}||k rm|||[a-z]+)://(?P.*)$s ^\s*(\w+)\s*s^\.\s*(\w+)\s*s^\[\s*(\w+)\s*\]\s*s^\d+$t ext_converttextt cfg_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 rtjd\}}td||f}|||_ |_ |nXdS(s` Resolve strings to objects using standard import and attribute syntax. t.iisCannot resolve %r: %sN( tsplitR!timportertgetattrtAttributeErrort ImportErrortsystexc_infoRt __cause__t __traceback__( RRtnametusedtfoundtfragtettbtv((s9/usr/lib/python2.7/site-packages/pip/compat/dictconfig.pytresolves"    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|jd}x|rJ|jj|}|r||jd}n|jj|}|r|jd}|j j|s||}qyt |}||}Wqt k r||}qXn|r1||j}qatd||fqaW|S(s*Default converter for the cfg:// protocol.sUnable to convert %risUnable to convert %r at %rN( t WORD_PATTERNRR%RtendR.tgroupst DOT_PATTERNt INDEX_PATTERNt DIGIT_PATTERNR R(RRtrestRtdR'tn((s9/usr/lib/python2.7/site-packages/pip/compat/dictconfig.pyR,s2     cC@s2t|t r7t|tr7t|}||_nt|t rnt|trnt|}||_nt|t rt|trt|}||_nt|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.pyRs*         c@sjd}t|d rUttdrUt|tjkrU|j|}njdd}tfdD}||}|rx-|jD]\}}t |||qWn|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 sN( R!thasattrttypesRRSRAR%Rtitemstsetattr(RR.tctpropstkwargsRR:R((R.s9/usr/lib/python2.7/site-packages/pip/compat/dictconfig.pytconfigure_customs4 cC@s"t|trt|}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@sheZdZdZdZdZdZdZdZe dZ e dZ e d Z RS( s] Configure logging using a dictionary-like object to describe the configuration. cC@sq|j}d|kr$tdn|ddkrKtd|dn|jdt}i}tjz|r|jd|}tjd dkrFx|D]}|tj krtd |qyItj |}||}|jd d}|r|j t |nWqt k r>} td || fqXqWn|jd |} xU| D]M}y|j|| |tWq_t k r} td || fq_Xq_W|jdd} | r^y|j| tWqt k r} td| qXq^nV|jdt} tj jtj2|jd|} xU| D]M}y|j| || |RfRgtdisable_existingRiRjtexistingt child_loggerstitprefixedtpflent num_existingtlogtlogger((s9/usr/lib/python2.7/site-packages/pip/compat/dictconfig.pyt configures                         cC@sd|kr|d}y|j|}Wqtk r}dt|krSn|jd|d<||d<|j|}qXn6|jdd}|jdd}tj||}|S(s(Configure a formatter from a dictionary.s()s'format'tformattfmttdatefmtN(R]RR R!RR%R t Formatter(RR.tfactoryRtteRtdfmt((s9/usr/lib/python2.7/site-packages/pip/compat/dictconfig.pyRus   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.pyRvs  cC@s]xV|D]N}y|j|jd|Wqtk rT}td||fqXqWdS(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.pyt add_filterss  c @sjdd}|r\y|jd|}Wq\tk rX}td||fq\Xnjdd}jdd}dkrjd}t|d rttdrt|tjkr|j |}n|}n|j jd }t |t j j rsd krsy|jd d d ss'stream'tstreamtstrmN(R!R%R.RpRRVRWRRSRAt issubclassR Ret MemoryHandlert SMTPHandlerR^t SysLogHandlerRRR t setFormatterRoR R( RR.RR>RRjRZRtklassR\RR((R.s9/usr/lib/python2.7/site-packages/pip/compat/dictconfig.pyRxsX 4     cC@s]xV|D]N}y|j|jd|Wqtk rT}td||fqXqWdS(s.Add handlers to a logger from a list of names.ResUnable to add handler %r: %sN(t addHandlerR.RpR(RRRethR>((s9/usr/lib/python2.7/site-packages/pip/compat/dictconfig.pyt add_handlers s  cC@s|jdd}|dk r4|jt|n|sx|jD]}|j|qEW|jdd}|r|j||n|jdd}|r|j||qndS(sU Perform configuration which is common to root and non-root loggers. RReRjN(RR%RoR Ret removeHandlerRR(RRR.RdRRReRj((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.RN(R t getLoggerRRR%R(RR:R.RdRR((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 RR(RR.RdRg((s9/usr/lib/python2.7/site-packages/pip/compat/dictconfig.pyRr+s ( R"R#R$RRuRvRRxRRkRRqRr(((s9/usr/lib/python2.7/site-packages/pip/compat/dictconfig.pyRbs   5   cC@st|jdS(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_R6RWt pip._vendorRR`tIRRR R5RRR&RR(RtobjectR)RbRR(((s9/usr/lib/python2.7/site-packages/pip/compat/dictconfig.pyts&       &