Repository URL to install this package:
|
Version:
1.0.11 ▾
|
wlanpi-profiler
/
opt
/
wlanpi-profiler
/
lib
/
python3.7
/
site-packages
/
pyparsing
/
__pycache__
/
exceptions.cpython-37.pyc
|
|---|
B
6ǫz9w`ã @ sÒ d dl Z d dlZd dlmZ ddlmZmZmZmZ ddl m
Z G dd dejej
ejejejZeejZe de d ¡ZG d
d deZG dd
d
eZG dd deZG dd deZG dd deZdS )é N)ÚOptionalé )ÚcolÚlineÚlinenoÚ_collapse_string_to_ranges)Úpyparsing_unicodec @ s e Zd ZdS )ÚExceptionWordUnicodeN)Ú__name__Ú
__module__Ú__qualname__© r
r
ú/build/wlanpi-profiler-7IIg1Q/wlanpi-profiler-1.0.11/debian/wlanpi-profiler/opt/wlanpi-profiler/lib/python3.7/site-packages/pyparsing/exceptions.pyr s r z([z
]{1,16})|.c @ sÌ e Zd ZdZd eeee dddZed!dd Z e
d
d Zeedd
dZ
eedddZeedddZeedddZedddZdd Zd"ddeedddZd#edddZeZdS )$ÚParseBaseExceptionz7base exception class for all parsing runtime exceptionsr N)ÚpstrÚlocÚmsgc C sD || _ |d kr|| _d| _n|| _|| _| | _| _|||f| _d S )NÚ )r r r Zparser_elementÚ
parserElementÚargs)Úselfr r r Úelemr
r
r Ú__init__ s zParseBaseException.__init__é c
C s ddl }ddlm} |dkr$t ¡ }g }t| trV| | j¡ | d| j d d ¡ | d
t| j| ¡¡ |dkrz|j
| j|d}t }xêt|| d
D ]Ô\}}|d } | j d d¡}
t|
|r| jjd
krÚq¢t|
|krèq¢| t|
¡ t|
}| d
|j|j|
¡¡ nP|
dk rBt|
}| d
|j|j¡¡ n&| j}|jd
krVq¢| d
|j¡¡ |d8 }|s¢P q¢W d |¡S )aì
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.
r Nr )Ú
ParserElementú ú^z{}: {})Úcontextr )Ú parseImplÚ
_parseNoCachez
{}.{} - {}z{}.{})Úwrapperz<module>z{}Ú
)ÚinspectÚcorer ÚsysÚgetrecursionlimitÚ
isinstancer Úappendr ÚcolumnÚformatÚtyper
ÚgetinnerframesÚ
__traceback__ÚsetÚ enumerateÚf_localsÚgetÚf_codeÚco_nameÚidÚaddr Újoin)
ÚexcÚdepthr" r ÚretÚcallersÚseenÚiÚffÚfrmÚf_selfÚ self_typeÚcoder
r
r Úexplain_exception) sH
z$ParseBaseException.explain_exceptionc C s | |j |j|j|jS )z¬
internal factory method to simplify creating one type of ParseException
from another - avoids having __init__ signature conflicts among subclasses
)r r r r )ÚclsÚper
r
r Ú_from_exceptionk s z"ParseBaseException._from_exception)Úreturnc C s t | j| jS )zG
Return the line of text where the exception occurred.
)r r r )r r
r
r r s s zParseBaseException.linec C s t | j| jS )zV
Return the 1-based line number of text where the exception occurred.
)r r r )r r
r
r r z s zParseBaseException.linenoc C s t | j| jS )z]
Return the 1-based column on the line of text where the exception occurred.
)r r r )r r
r
r r s zParseBaseException.colc C s t | j| jS )z]
Return the 1-based column on the line of text where the exception occurred.
)r r r )r r
r
r r( s zParseBaseException.columnc C s | j rh| jt| j krd}qlt | j | j¡}|d k r@| d¡}n| j | j| jd
}d| dd¡}nd}d | j|| j| j | j
¡S ) Nz, found end of textr r z
, found %rz\\ú\r z%{}{} (at char {}), (line:{}, col:{}))r r ÚlenÚ_exception_word_extractorÚmatchÚgroupÚreplacer) r r r( )r ÚfoundstrZfound_matchÚfoundr
r
r Ú__str__ s zParseBaseException.__str__c C s t | S )N)Ústr)r r
r
r Ú__repr__¡ s zParseBaseException.__repr__z>!<)ÚmarkerString)Ú
marker_stringrE c C sL |dk r|n|}| j }| jd }|rDd |d|
|||d
f¡}| ¡ S )z
Extracts the exception line from the input string, and marks
the location of the exception with a special symbol.
Nr r )r r( r5 Ústrip)r rR rQ Úline_strÚline_columnr
r
r Úmark_input_line¤ s
z"ParseBaseException.mark_input_linec C s | | |¡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::
expr = pp.Word(pp.nums) * 3
try:
expr.parse_string("123 456 A789")
except pp.ParseException as pe:
print(pe.explain(depth=0))
prints::
123 456 A789
^
ParseException: Expected W:(0-9), found 'A' (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``
)rA )r r7 r
r
r Úexplain² s %zParseBaseException.explain)r NN)r )N)r )r
r r Ú__doc__rO Úintr r ÚstaticmethodrA ÚclassmethodrD Úpropertyr r r r( rN rP rV rW Ú
markInputliner
r
r
r r s( A'r c @ s e Zd ZdZdS )ÚParseExceptionaq
Exception thrown when a parse expression doesn't match the input string
Example::
try:
Word(nums).set_name("integer").parse_string("ABC")
except ParseException as pe:
print(pe)
print("column: {}".format(pe.column))
prints::
Expected integer (at char 0), (line:1, col:1)
column: 1
N)r
r r rX r
r
r
r r^ Ü s r^ c @ s e Zd ZdZdS )ÚParseFatalExceptionzu
User-throwable exception thrown when inconsistent parse content
is found; stops all parsing immediately
N)r
r r rX r
r
r
r r_ ð s r_ c @ s e Zd ZdZdS )ÚParseSyntaxExceptionzó
Just like :class:`ParseFatalException`, but thrown internally
when an :class:`ErrorStop<And._ErrorStop>` ('-' operator) indicates
that parsing is to stop immediately because an unbacktrackable
syntax error has been found.
N)r
r r rX r
r
r
r r` ÷ s r` c @ s&