Repository URL to install this package:
|
Version:
1.0.11 ▾
|
wlanpi-profiler
/
opt
/
wlanpi-profiler
/
lib
/
python3.7
/
site-packages
/
pyparsing
/
__pycache__
/
helpers.cpython-37.pyc
|
|---|
B
P
°IÜÛ2ã
@ s¨ d dl Zd dlZddlmZ ddlT ddlmZmZm Z dSdde
eef e
eef e
ee ee e
ed d
dZdTddeee ee ed
ddZeedddZeedddZdUddde
ee ef e
e
e
e
e
edddZeeedddZdVddee
e
eddd Zeedd!d"Zeedd#d$Zd%d&de fe d'e
eef e
eef ee eeed(d)d*Zed+ed,fd-d.Ze
eef eeef d/d0d1Ze
eef eeef d/d2d3Z ee!e"e#d4 $d5¡\Z%Z&d6d7 ej'j( )¡ D Z*e+d8d9 ,e*¡ d: $d;¡Z-d<d= Z.G d>d? d?e/Z0e
eeee
eef e
eef f f Z1e
ee1ee0ee2 f ee1ee0f f Z3ed%ed&fee4e3 e
eef e
eef ed@dAdBZ5dg fdCdDZ6e7e+dEdF $dG¡Z8e+dH $dI¡Z9e+dJ :¡ $dK¡Z;e+dL $dM¡Z<e7e+dEdF e<B $dN¡Z=e=Z>e+dO $dP¡Z?dQdR e@ A¡ D ZBeZCeZDeZEeZFeZGeZHeZIeZJeZKe ZLe%e& ZMZNe-ZOe.ZPe0ZQe5ZRe8ZSe9ZTe;ZUe<ZVe=ZWe>ZXe?ZYdS )Wé Né )Ú__diag__)Ú*)Ú_bslashÚ_flattenÚ_escape_regex_range_charsú,F)Úallow_trailing_delim)ÚexprÚdelimÚcombineÚminÚmaxr Úreturnc C sÞ t | trt | ¡} djt| ¡ ¡ t||r>d t|¡ndd}|sRt|}|dk rr|dk rjt d|d8 }|dk r|dk r||krt d|d8 }| || ||f }|r¾|t
|7 }|rÐt| |¡S | |¡S dS ) a/ Helper to define a delimited list of expressions - the delimiter
defaults to ','. By default, the list elements and delimiters can
have intervening whitespace, and comments, but this can be
overridden by passing ``combine=True`` in the constructor. If
``combine`` is set to ``True``, the matching tokens are
returned as a single token string, with the delimiters included;
otherwise, the matching tokens are returned as a list of tokens,
with the delimiters suppressed.
If ``allow_trailing_delim`` is set to True, then the list may end with
a delimiter.
Example::
delimited_list(Word(alphas)).parse_string("aa,bb,cc") # -> ['aa', 'bb', 'cc']
delimited_list(Word(hexnums), delim=':', combine=True).parse_string("AA:BB:CC:DD:EE") # -> ['AA:BB:CC:DD:EE']
z{expr} [{delim} {expr}]...{end}z [{}]Ú )r
r ÚendNr zmin must be greater than 0z)max must be greater than, or equal to min)
Ú
isinstanceÚstr_typeÚ
ParserElementÚ_literalStringClassÚformatÚstrÚcopyÚ
streamlineÚSuppressÚ
ValueErrorÚOptÚCombineÚset_name)r
r r r
r r ÚdlNameZdelimited_list_expr© r ú/build/wlanpi-profiler-7IIg1Q/wlanpi-profiler-1.0.11/debian/wlanpi-profiler/opt/wlanpi-profiler/lib/python3.7/site-packages/pyparsing/helpers.pyÚdelimited_list
s,
r" )ÚintExpr)r
Úint_exprr# r c sr |p|}t fdd}|dkr8tt dd ¡}n| ¡ }| d¡ |j|dd | d t d
¡S )a~ Helper to define a counted list of expressions.
This helper defines a pattern of the form::
integer expr expr expr...
where the leading integer tells how many expr expressions follow.
The matched tokens returns the array of expr tokens as a list - the
leading count token is suppressed.
If ``int_expr`` is specified, it should be a pyparsing expression
that produces an integer value.
Example::
counted_array(Word(alphas)).parse_string('2 ab cd ef') # -> ['ab', 'cd']
# in this parser, the leading integer value is given in binary,
# '10' indicating that 2 values are in the array
binary_constant = Word('01').set_parse_action(lambda t: int(t[0], 2))
counted_array(Word(alphas), int_expr=binary_constant).parse_string('10 ab cd ef') # -> ['ab', 'cd']
# if other fields must be parsed after the count but before the
# list items, give the fields results names and they will
# be preserved in the returned ParseResults:
count_with_metadata = integer + Word(alphas)("type")
typed_array = counted_array(Word(alphanums), int_expr=count_with_metadata)("items")
result = typed_array.parse_string("3 bool True True False")
print(result.dump())
# prints
# ['True', 'True', 'False']
# - items: ['True', 'True', 'False']
# - type: 'bool'
c s, |d } |r| nt K |d d
= d S )Nr )ÚEmpty)ÚsÚlÚtÚn)Ú
array_exprr
r r! Úcount_field_parse_actionr s z/counted_array.<locals>.count_field_parse_actionNc S s t | d S )Nr )Úint)r( r r r! Ú<lambda>z ó zcounted_array.<locals>.<lambda>ÚarrayLenT)Zcall_during_tryz(len) z...)ÚForwardÚWordÚnumsÚset_parse_actionr r Úadd_parse_actionr )r
r$ r# r+ r )r* r
r! Ú
counted_arrayF s )
r5 )r
r c s6 t fdd}| j|dd dt| ¡ S )a9 Helper to define an expression that is indirectly defined from
the tokens matched in a previous expression, that is, it looks for
a 'repeat' of a previous expression. For example::
first = Word(nums)
second = match_previous_literal(first)
match_expr = first + ":" + second
will match ``"1:1"``, but not ``"1:2"``. Because this
matches a previous literal, will also match the leading
``"1:1"`` in ``"1:10"``. If this is not desired, use
:class:`match_previous_expr`. Do *not* use with packrat parsing
enabled.
c sP |rBt |dkr |d >