Plan 9 from Bell Labs’s /usr/web/sources/contrib/bichued/root/sys/lib/python/warnings.pyc

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


�
��c	@s1dZddkZddkZddkZdddddgZgZdZhZdd	d
�Z	dddd�Z
dd�Zd
�Zde
dddd�Ze
ddd�Zd�Zdefd��YZd�Zd�Zd�Zd�Zeei�eddedd	�eddedd	�dS(s&Python part of the warnings subsystem.i�Ntwarntshowwarningt
formatwarningtfilterwarningst
resetwarningstdefaultic
Cs{t|t�o
|i}n|djo
t}nt|t�pt�yti|�}Wn"t	j
oti
}d}nX|i}|i}d|jo|d}nd}|i
d�}|o.|i�}|id�o|d }qInP|djo1ytid	}Wq8tj
o
d}q8Xn|p
|}n|id
h�}	t||||||	|�dS(
s:Issue a warning, or maybe ignore it or raise an exception.it__name__s<string>t__file__s.pycs.pyoi�t__main__it__warningregistry__N(s.pycs.pyo(t
isinstancetWarningt	__class__tNonetUserWarningt
issubclasstAssertionErrortsyst	_getframet
ValueErrort__dict__t	f_globalstf_linenotgettlowertendswithtargvtAttributeErrort
setdefaultt
warn_explicit(
tmessagetcategoryt
stackleveltcallertglobalstlinenotmoduletfilenametfnltregistry((s/sys/lib/python/warnings.pyRs<


			


c	Cs�|djo6|pd}|di�djo|d }qCn|djo
h}nt|t�ot|�}|i}n|}||�}|||f}|i|�odSnx�tD]�}	|	\}
}}}
}|djp|i|�oLt	||�o<|
djp|
i|�o|djp
||joPq�q�Wt
}
|
djod||<dSnti||�|
djo
|�n|
djo<d||<||f}t
i|�odSndt
|<n�|
d	jon~|
d
jo?d||<||df}|i|�odSnd||<n2|
djod||<ntd|
|	f��t||||�dS(
Ns	<unknown>i�s.pyitignoreiterrortoncetalwaysR$Rs1Unrecognized action (%r) in warnings.filters:
 %s(R
RR
RtstrRRtfilterstmatchRt
defaultactiont	linecachetgetlinestonceregistrytRuntimeErrorR(RRR%R#R$R'tmodule_globalsttexttkeytitemtactiontmsgtcattmodtlntoncekeytaltkey((s/sys/lib/python/warnings.pyR@sb




	









c	CsT|djo
ti}ny |it||||��Wntj
onXdS(s7Hook to write a warning to a file; replace if you like.N(R
RtstderrtwriteRtIOError(RRR%R#tfile((s/sys/lib/python/warnings.pyR�s

 cCsRd|||i|f}ti||�i�}|o|d|d}n|S(s.Function to format a warning the standard way.s%s:%s: %s: %s
s  s
(RR0tgetlinetstrip(RRR%R#tstline((s/sys/lib/python/warnings.pyR�s
ticCsddk}|djptd	|f�t|t�p
td
�t|ttif�p
td�t|t�p
td�t|t�p
td
�t|t	�o
|djp
td�||i
||i�||i
|�|f}|oti
|�ntid|�dS(s�Insert an entry into the list of warnings filters (at the front).

    Use assertions to check that all arguments have the right type.i�NR)R(R+RR$R*sinvalid 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(treRR
t
basestringttypettypest	ClassTypeRRtinttcompiletIR-tappendtinsert(R8RRR$R#RPRHR7((s/sys/lib/python/warnings.pyR�s cCs�|djptd|f�t|t�o
|djp
td	�|d
|d
|f}|oti|�ntid|�d
S(s�Insert a simple entry into the list of warnings filters (at the front).

    A simple filter matches all modules and messages.
    R)R(R+RR$R*sinvalid action: %rislineno must be an int >= 0N(serrorsignoresalwayssdefaultsmodulesonce(RR
RMR
R-RPRQ(R8RR#RPR7((s/sys/lib/python/warnings.pytsimplefilter�s cCsgt(dS(sAClear the list of warning filters, so that no filters are active.N(R-(((s/sys/lib/python/warnings.pyR�st_OptionErrorcBseZdZRS(s,Exception used by option processing helpers.(Rt
__module__t__doc__(((s/sys/lib/python/warnings.pyRS�scCsNxG|D]?}yt|�Wqtj
o}tidI|IJqXqWdS(NsInvalid -W option ignored:(t
_setoptionRSRR?(targstargR9((s/sys/lib/python/warnings.pyt_processoptions�sc
Csoddk}|id�}t|�djotd|f��nx%t|�djo|id�qHWg}|D]}||i�qx~\}}}}}	t|�}|i|�}t|�}|i|�}|o|d}n|	oZy't	|	�}	|	djo
t
�nWqUt
tfj
otd|	f��qUXnd}	t|||||	�dS(	Ni�t:istoo many fields (max 5): %rRGt$isinvalid lineno %r(
RHtsplittlenRSRPRDt
_getactiontescapet_getcategoryRMRt
OverflowErrorR(
RXRHtpartst_[1]RER8RRR$R#((s/sys/lib/python/warnings.pyRV�s./
cCsd|pdSn|djodSnx&d	D]}|i|�o|Sq+q+Wtd|f��dS(
NRtallR+R(R$R*R)sinvalid action: %r(sdefaultsalwayssignoresmodulesonceserror(t
startswithRS(R8ta((s/sys/lib/python/warnings.pyR^�scCs>ddk}|ptSn|id|�o=yt|�}Wqtj
otd|f��qXn�|id�}|| }||d}yt|dd|g�}Wn&t	j
otd|f��nXyt
||�}Wn&tj
otd|f��nXt|t�ptd|f��n|S(Ni�s^[a-zA-Z0-9_]+$sunknown warning category: %rt.isinvalid module name: %rsinvalid warning category: %r(
RHRR.tevalt	NameErrorRStrfindt
__import__R
tImportErrortgetattrRR(RRHR:tiR$tklasstm((s/sys/lib/python/warnings.pyR`�s,
R(RRP(RURRKR0t__all__R-R/R2R
RRRRRRRRRt	ExceptionRSRYRVR^R`twarnoptionstPendingDeprecationWarningt
ImportWarning(((s/sys/lib/python/warnings.pys<module>s.	
)?						
	


Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.