Files
intellecton/venv/lib/python3.12/site-packages/pyparsing/__pycache__/exceptions.cpython-312.pyc
T

159 lines
14 KiB
Plaintext
Raw Normal View History

Ë
vRjå*ã ó¼ddlmZddlZddlZddlZddlZddlZddlmZddlm Z ddl
m Z ddl
mZmZmZmZmZmZGdd e j(e j*e j,e j.e j0«Zeej4«Zej8d
ed «ZGd d
e«ZGdde«Z Gdde«Z!Gdde!«Z"Gdde«Z#y)é)Ú annotationsN)Úcached_propertyé)ÚPyparsingDeprecationWarning)Úpyparsing_unicode)Ú_collapse_string_to_rangesÚcolÚdeprecate_argumentÚlineÚlinenoÚreplaced_by_pep8có eZdZy)Ú_ExceptionWordUnicodeSetN)Ú__name__Ú
__module__Ú __qualname__©óúW/home/antigravity/intellecton/venv/lib/python3.12/site-packages/pyparsing/exceptions.pyrrsð rrz([z
]{1,16})|.códeZdZUdZded<ded<ded<ded<d ed
<d Z d dd
Zed d!d«Ze d"d«Z
e d#d«Z e d$d«Z
e d$d«Ze d$d«Ze d#d«Zed«Zej&d«ZdZd#dZd#dZdZ d% d&dZd d'dZede«Zy )(ÚParseBaseExceptionz7base exception class for all parsing runtime exceptionsÚintÚlocÚstrÚmsgÚpstrz
typing.AnyÚparser_elementz%tuple[str, int, typing.Optional[str]]Úargs©rrrrrNcó\||d}}||_||_||_||_|||f|_y)r)ÚselfrrrÚelems rÚ__init__zParseBaseException.__init__4s=ð ˆ;ؘbˆCàˆŒØˆŒØˆŒ ØÔؘ3 Ð$ˆ rcóVddl}ddlm}|tj«}g}t |t «r<|j|j«|jdd|jd«|jt|«jd|«|dks |jd j|«S|j|j|¬
«}t«}|| dD]/}|d}|j j#d d«} t | |«r‡|j$j&j)d «sŒWt+| «|vrŒe|j-t+| ««t| «}
|j|
j.d
|
jd| «no| 6t| «}
|j|
j.d
|
j«n7|j$} | j&dvrŒ |j| j&«|dz}|rŒ0nd j|«S)
Method to take an exception and translate the Python internal traceback into a list
of the pyparsing expressions that caused the exception to be raised.
Parameters:
- exc - exception raised during parsing (need not be a ParseException, in support
of Python exceptions that might be raised in a parse action)
- depth (default=16) - number of levels back in the stack trace to list expression
and function names; if None, the full stack trace names will be listed; if 0, only
the failing input line, marker, and exception string will be shown
Returns a multi-line string listing the ParserElements and/or function names in the
exception's stack trace.
rNr)Ú
ParserElementú>r!ú: ú
)Úcontextr")Ú parseImplÚ
_parseNoCacheú.z - )Úwrapperz<module>)ÚinspectÚcorer&ÚsysÚgetrecursionlimitÚ
isinstancerÚappendr ÚcolumnÚtyperÚ
__traceback__ÚjoinÚgetinnerframesÚsetÚf_localsÚgetÚf_codeÚco_nameÚ
startswithÚidÚaddr) ÚexcÚdepthr0r&ÚretÚcallersÚseenÚffÚfrmÚf_selfÚ self_typeÚcodes rÚexplain_exceptionz$ParseBaseException.explain_exceptionDó" Ý ˆ×+ˆEØˆÜ  J‰Js—x Ø J‰J˜#˜a §
¡
˜|¨0˜ 
”d˜3“iרC¨5Ð AŠ:˜×—9‘9˜S“>Ð ××):Ñ):ÀEÐJˆÜˆØ˜5˜&˜ ˆQ%ˆ—\‘\×% f¨dÓ3ˆ˜& —zz×)×4Ð5SÔÜf“: ÑØœ˜F›Ô  ›L Ø
˜i×3°1°Y×5GÑ5GÐ4HÈÈFÈ8ÐÐ  ›L Ø
˜i×3°1°Y×5GÑ5GÐ4HЗzzØ—<<Ð#:Ñà
˜4Ÿ<™<Ô Q‰JˆÙð7 ð:y‰y˜rcóh||j|j|j|j«S)
internal factory method to simplify creating one type of ParseException
from another - avoids having __init__ signature conflicts among subclasses
)rrrr)ÚclsÚpes rÚ_from_exceptionz"ParseBaseException._from_exception„s'ñ 2—77˜BŸF™F B§F¡F¨B×,=Ñ,=Ó>rcóBt|j|j«S)zG
Return the line of text where the exception occurred.
)r rr©r"s rr zParseBaseException.lineŒsô
D—HH˜dŸi™iÓ(rcóBt|j|j«S)zV
Return the 1-based line number of text where the exception occurred.
)r rrrSs rr zParseBaseException.lineno“sô
d—hh § ¡ Ó*rcóBt|j|j«S©z]
Return the 1-based column on the line of text where the exception occurred.
©r rrrSs rr zParseBaseException.colšóô
4—88˜TŸY™YÓ'rcóBt|j|j«SrVrWrSs rr6zParseBaseException.column¡rXrcóH|jsy|jt|j«k\rytj |j|j«}||d}n&|j|j|jdz}t |«j
dd«S)Nr!z end of textrrz\\ú\)rrÚlenÚ_exception_word_extractorÚmatchÚreprÚreplace)r"Ú found_matchÚ
found_texts rÚfoundzParseBaseException.found¨sàyŠyØà 8‰8”s˜4Ÿ9™9“~Ò  ô5°d·i±iÀÇÁÓ Ø Ð $ Q™‰JàŸ 4§8¡8¨d¯h©h¸©lÐ;ˆ×¨tÓ4rcóRtjdtd¬«|jS©Nz/parserElement is deprecated, use parser_elementé)Ú
stacklevel©ÚwarningsÚwarnrrrSs rÚ
parserElementz ParseBaseException.parserElementºs%ä
Ø õ
ð
×"rcóJtjdtd¬«||_yrerh)r"r#s rrkz ParseBaseException.parserElementÃs!ä
Ø õ
ð
#ˆÕrcó,tj|«S©N)ÚcopyrSs rrozParseBaseException.copyÌsÜy‰y˜Ðrc ó¬|jrd|jnd}|j|d|jd|jd|jd S)
Output the formatted exception message.
Can be overridden to customize the message formatting or contents.
.. versionadded:: 3.2.0
z, found r!z (at char z ), (line:z, col:ú))rcrrr r6)r"Ú found_phrases rÚformatted_messagez$ParseBaseException.formatted_messageÏsUð37·*²*˜ $§*¡* Ñ.À"ˆ Ø—((˜L˜°T·X±X°J¸Ï É À}ÐTZÐ[_×[fÑ[fÐZgÐghÐirc óÌ |j«S#t$rH}t|«jd|jdt|«jd|dcYd}~Sd}~wwxYw)zl
.. versionchanged:: 3.2.0
Now uses :meth:`formatted_message` to format message.
r)z (z while formatting message)N)rsÚ Exceptionr7rr)r"Úexs rÚ__str__zParseBaseException.__str__Ùsfð
 Ø× +øÜò 䘓:×' r¨$¯(©(¨Ø”T˜"“X×' r¨"¨Ð-GðIõ
ûð ús A#=AÁA#ÁA#cót|«Srn)rrSs rÚ__repr__zParseBaseException.__repr__æs Ü4rc óžt|dd«}||n|}|j}|jdz
}|r|d||||d}|j«S)z
Extracts the exception line from the input string, and marks
the location of the exception with a special symbol.
Ú markerStringz>!<Nr)r
r r6Ústrip)r"Ú
marker_stringÚkwargsr{Úline_strÚ line_columns rÚmark_input_linez"ParseBaseException.mark_input_lineésfô/¨v°~ÀuÓ à(5Ð(A‘}À|ˆ Ø—9‘9ˆØ—k‘k Aoˆ Ù Ø" < 1°,°ÀÈÈÐ@VÐ?WÐXˆHØ~‰~ÓÐrcó&|j||«S)a¸
Method to translate the Python internal traceback into a list
of the pyparsing expressions that caused the exception to be raised.
Parameters:
- depth (default=16) - number of levels back in the stack trace to list expression
and function names; if None, the full stack trace names will be listed; if 0, only
the failing input line, marker, and exception string will be shown
Returns a multi-line string listing the ParserElements and/or function names in the
exception's stack trace.
Example:
.. testcode::
# an expression to parse 3 integers
expr = pp.Word(pp.nums) * 3
try:
# a failing parse - the third integer is prefixed with "A"
expr.parse_string("123 456 A789")
except pp.ParseException as pe:
print(pe.explain(depth=0))
prints:
.. testoutput::
123 456 A789
^
ParseException: Expected W:(0-9), found 'A789' (at char 8), (line:1, col:9)
Note: the diagnostic output will include string representations of the expressions
that failed to parse. These representations will be more helpful if you use `set_name` to
give identifiable names to your expressions. Otherwise they will use the default string
forms, which may be cryptic to read.
Note: pyparsing's default truncation of exception tracebacks may also truncate the
stack of expressions that are displayed in the ``explain`` output. To get the full listing
of parser expressions, you may have to set ``ParserElement.verbose_stacktrace = True``
)rM)r"rDs rÚexplainzParseBaseException.explainùsðV×% d¨EÓ2rÚ
markInputline)rNN)rrrrrútyping.Optional[str]ÚreturnÚNone)é)rCrurDrr†r)r†r©r†r)r†rrn)r}r…r†r)rDrr†r)rrrÚ__doc__Ú__annotations__Ú __slots__r$Ú staticmethodrMÚ classmethodrQrr r r r6rcÚpropertyrkÚsetterrorsrwryrr
r„rrrrr!s[Ù ƒHØ ƒHØ
ƒIØÓØ
€IðØ$(Ø
ð ðð
ó
ó=óð=ð~òðòð òð òð òð òð5ð"ñð×Ññðójó òð59ð Ø à ó ô +3ñ^% _°oÓFMrrcóeZdZdZy)ÚParseExceptiona
Exception thrown when a parse expression doesn't match the input string
Example:
.. testcode::
integer = Word(nums).set_name("integer")
try:
integer.parse_string("ABC")
except ParseException as pe:
print(pe, f"column: {pe.column}")
prints:
.. testoutput::
Expected integer, found 'ABC' (at char 0), (line:1, col:1) column: 1