nfc@sSdZddlZddlZddlZddddddgZdd d Zddd ZeZdd Z d e d dddZ e dddZ dZ defdYZdZdZdZdZdd dZddddZdefdYZdefdYZeZy>ddlmZmZmZmZmZeZeZ e!ZWn#e"k rgZdZiZ nXeej#esLe$e%gZ&ej' rej(j) re&j*e+nxe&D]Z,e dd e,qWej(j-Z-e-d krd!Z.ne-r-dZ.ndZ.e e.d e/d"d n[dS(#s&Python part of the warnings subsystem.iNtwarnt showwarningt formatwarningtfilterwarningst resetwarningstcatch_warningsicCs9tjr5|dkrt}nt|||dndS(sIssue a deprecation warning for Python 3.x related changes. Warnings are omitted unless Python is started with the -3 option. iN(tsyst py3kwarningtNonetDeprecationWarningR(tmessagetcategoryt stacklevel((s /usr/lib64/python2.7/warnings.pytwarnpy3ks   cCsS|dkrtj}ny#|jt|||||Wntk rNnXdS(s7Hook to write a warning to a file; replace if you like.N(RRtstderrtwriteRtIOError(R R tfilenametlinenotfiletline((s /usr/lib64/python2.7/warnings.pyt _show_warnings   # cCsdd|||j|f}|dkr7tj||n|}|r`|j}|d|7}n|S(s.Function to format a warning the standard way.s%s:%s: %s: %s s %s N(t__name__Rt linecachetgetlinetstrip(R R RRRts((s /usr/lib64/python2.7/warnings.pyR$s $ ticCsddl}|dks+td |ft|tsFtd t|ttjfsjtd t|tstd t|tstd t|t r|dkstd||j ||j ||j ||f}|r t j |nt jd|dS(sInsert an entry into the list of warnings filters (at the front). 'action' -- one of "error", "ignore", "always", "default", "module", or "once" 'message' -- a regex that the warning message must match 'category' -- a class that the warning must be a subclass of 'module' -- a regex that the module name must match 'lineno' -- an integer line number, 0 matches all warnings 'append' -- if true, append to the list of filters iNterrortignoretalwaystdefaulttmoduletoncesinvalid action: %rsmessage must be a stringscategory must be a classs#category must be a Warning subclasssmodule must be a stringislineno must be an int >= 0(serrorsignoresalwayssdefaultsmodulesonce(tretAssertionErrort isinstancet basestringttypettypest ClassTypet issubclasstWarningtinttcompiletItfilterstappendtinsert(tactionR R R RR/R"titem((s /usr/lib64/python2.7/warnings.pyR-s   cCs|d kstd|ft|tr:|dksFtd |d |d |f}|rqtj|ntjd|d S( sInsert a simple entry into the list of warnings filters (at the front). A simple filter matches all modules and messages. 'action' -- one of "error", "ignore", "always", "default", "module", or "once" 'category' -- a class that the warning must be a subclass of 'lineno' -- an integer line number, 0 matches all warnings 'append' -- if true, append to the list of filters RRRRR R!sinvalid action: %rislineno must be an int >= 0N(serrorsignoresalwayssdefaultsmodulesonce(R#R$R+RR.R/R0(R1R RR/R2((s /usr/lib64/python2.7/warnings.pyt simplefilterJs  cCs gt(dS(sAClear the list of warning filters, so that no filters are active.N(R.(((s /usr/lib64/python2.7/warnings.pyR^st _OptionErrorcBseZdZRS(s,Exception used by option processing helpers.(Rt __module__t__doc__(((s /usr/lib64/python2.7/warnings.pyR4bscCsLxE|D]=}yt|Wqtk rC}tjdI|IJqXqWdS(NsInvalid -W option ignored:(t _setoptionR4RR(targstargtmsg((s /usr/lib64/python2.7/warnings.pyt_processoptionsgs  c Cs[ddl}|jd}t|dkrCtd|fnx#t|dkrh|jdqFWg|D]}|j^qp\}}}}}t|}|j|}t|}|j|}|r|d}n|r;y%t |}|dkr t nWqAt t fk r7td|fqAXnd}t |||||dS( Nit:istoo many fields (max 5): %rRt$isinvalid lineno %r( R"tsplittlenR4R/Rt _getactiontescapet _getcategoryR+t ValueErrort OverflowErrorR( R9R"tpartsRR1R R R R((s /usr/lib64/python2.7/warnings.pyR7os. +      cCsU|s dS|dkrdSx!d D]}|j|r!|Sq!Wtd|fdS( NRtallRRR R!Rsinvalid action: %r(sdefaultsalwayssignoresmodulesonceserror(t startswithR4(R1ta((s /usr/lib64/python2.7/warnings.pyR@s  cCs/ddl}|stS|jd|rbyt|}Wqtk r^td|fqXn|jd}|| }||d}yt|dd|g}Wn$t k rtd|fnXyt ||}Wn$t k rtd|fnXt |ts+td|fn|S(Nis^[a-zA-Z0-9_]+$sunknown warning category: %rt.isinvalid module name: %rsinvalid warning category: %r( R"R*tmatchtevalt NameErrorR4trfindt __import__Rt ImportErrortgetattrtAttributeErrorR)(R R"tcattiR tklasstm((s /usr/lib64/python2.7/warnings.pyRBs,     c Csgt|tr|j}n|d kr0t}nt|tsEtytj|}Wn t k rztj }d}nX|j }|j }d|kr|d}nd}|j d}|r|j}|jd r5|d }q5nI|dkr&ytjd }Wq&tk r"d}q&Xn|s5|}n|jd i} t|||||| |d S( s:Issue a warning, or maybe ignore it or raise an exception.iRst__file__s.pycs.pyoit__main__it__warningregistry__N(s.pycs.pyo(R$R*t __class__Rt UserWarningR)R#Rt _getframeRCt__dict__t f_globalstf_linenotgettlowertendswithtargvRQt setdefaultt warn_explicit( R R R tcallertglobalsRR Rtfnltregistry((s /usr/lib64/python2.7/warnings.pyRs<               c Csbt|}|dkrJ|p!d}|djdkrJ|d }qJn|dkr_i}nt|trt|}|j}n|}||}|||f}|j|rdSxtD]|} | \} } } } }| dks| j |rt || r| dks!| j |r|dks9||krPqqWt } | dkrad||is.pyiRiRR!RR Rs1Unrecognized action (%r) in warnings.filters: %s(R+RR`R$R*tstrRYR_R.RJR)t defaultactionRtgetlinest onceregistryt RuntimeErrorR(R R RRR Rhtmodule_globalsttexttkeyR2R1R:RRtmodtlntoncekeytaltkey((s /usr/lib64/python2.7/warnings.pyRdsb                       tWarningMessagecBs,eZdZd Zd d dZdZRS( s0Holds the result of a single showwarning() call.R R RRRRc CsMt}x%|jD]}t||||qW|r@|jnd|_dS(N(tlocalst_WARNING_DETAILStsetattrRRt_category_name( tselfR R RRRRt local_valuestattr((s /usr/lib64/python2.7/warnings.pyt__init__ s cCs&d|j|j|j|j|jfS(NsD{message : %r, category : %r, filename : %r, lineno : %s, line : %r}(R RyRRR(Rz((s /usr/lib64/python2.7/warnings.pyt__str__'s (smessagescategorysfilenameslinenosfileslineN(RR5R6RwRR}R~(((s /usr/lib64/python2.7/warnings.pyRus  cBs8eZdZeddZdZdZdZRS(sA context manager that copies and restores the warnings filter upon exiting the context. The 'record' argument specifies whether warnings should be captured by a custom implementation of warnings.showwarning() and be appended to a list returned by the context manager. Otherwise None is returned by the context manager. The objects appended to the list are arguments whose attributes mirror the arguments to showwarning(). The 'module' argument is to specify an alternative module to the module named 'warnings' and imported under that name. This argument is only useful when testing the warnings module itself. cCs8||_|dkr"tjdn||_t|_dS(sSpecify whether to record warnings and if an alternative module should be used other than sys.modules['warnings']. For compatibility with Python 3.0, please consider all arguments to be keyword-only. twarningsN(t_recordRRtmodulest_moduletFalset_entered(RztrecordR ((s /usr/lib64/python2.7/warnings.pyR}>s "cCsrg}|jr|jdn|jtjdk rL|jd|jnt|j}d|dj|fS(Ns record=TrueRs module=%rs%s(%s)s, (RR/RRRR&Rtjoin(RzR8tname((s /usr/lib64/python2.7/warnings.pyt__repr__Js cs|jrtd|nt|_|jj|_|j|j_|jj|_|jrgfd}||j_SdSdS(NsCannot enter %r twicecsjt||dS(N(R/Ru(R8tkwargs(tlog(s /usr/lib64/python2.7/warnings.pyR\s( RRmtTrueRR.t_filtersRt _showwarningRR(RzR((Rs /usr/lib64/python2.7/warnings.pyt __enter__Ss    cGs>|jstd|n|j|j_|j|j_dS(Ns%Cannot exit %r without entering first(RRmRRR.RR(Rztexc_info((s /usr/lib64/python2.7/warnings.pyt__exit__cs N( RR5R6RRR}RRR(((s /usr/lib64/python2.7/warnings.pyR-s  (R.tdefault_actiont once_registryRRdRRR RR/(0R6RRR't__all__RR RRRR*RR3Rt ExceptionR4R;R7R@RBRRdtobjectRuRRt_warnings_defaultst _warningsR.RRRjRlRROt warnoptionst ImportWarningtPendingDeprecationWarningtsilenceRtflagstdivision_warningR/R tclst bytes_warningt bytes_actiont BytesWarning(((s /usr/lib64/python2.7/warnings.pyts^             )AE(