403Webshell
Server IP : 127.0.0.1  /  Your IP : 216.73.216.109
Web Server : Apache/2.4.54 (Win64) OpenSSL/1.1.1q PHP/8.1.10
System : Windows NT DESKTOP-E5T4RUN 10.0 build 19045 (Windows 10) AMD64
User : SERVERWEB ( 0)
PHP Version : 8.1.10
Disable Function : NONE
MySQL : OFF |  cURL : ON |  WGET : OFF |  Perl : OFF |  Python : OFF |  Sudo : OFF |  Pkexec : OFF
Directory :  C:/cygwin64/lib/python3.9/site-packages/pyparsing/__pycache__/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : C:/cygwin64/lib/python3.9/site-packages/pyparsing/__pycache__/results.cpython-39.pyc
a

�l�a�b�@s�UddlmZmZmZmZddlZddlmZddl	m
Z
mZee
fZe
edfed<edd�d	D��ZGd
d�d�ZGdd
�d
�Ze�e�e�e�dS)�)�MutableMapping�Mapping�MutableSequence�IteratorN)�ref)�Tuple�Any.�str_typeccs|]
}|VqdS�N�)�.0�_rr�5/usr/lib/python3.9/site-packages/pyparsing/results.py�	<genexpr>�rrc@s2eZdZdgZdd�Zdd�Zdd�Zdd	�Zd
S)�_ParseResultsWithOffset�tupcCs||f|_dSr
�r)�selfZp1Zp2rrr�__init__sz _ParseResultsWithOffset.__init__cCs
|j|Sr
r�r�irrr�__getitem__sz#_ParseResultsWithOffset.__getitem__cCs|jSr
r�rrrr�__getstate__sz$_ParseResultsWithOffset.__getstate__cGs|d|_dS�Nrr)r�argsrrr�__setstate__sz$_ParseResultsWithOffset.__setstate__N)�__name__�
__module__�__qualname__�	__slots__rrrrrrrrrs
rc@seZdZUdZdgddfZeedfed<gd�ZGdd	�d	e	�Z
dYd
d�Zddddefd
d�Z
dd�Zefdd�Zdd�Zed�dd�Zed�dd�Zed�dd�Zed�dd�Zed�dd�Zd d!�Zd"d#�Zd$d%�Zed�d&d'�Zd(d)�ZdZd*d+�Zd,d-�Zd.d/�Z d0d1�Z!d2d3�Z"d4d5�Z#dd�d6d7�Z$dd�d8d9�Z%dd�d:d;�Z&e'd�d<d=�Z(e'd�d>d?�Z)d[d@dA�Z*e	d�dBdC�Z+e,d�dDdE�Z-dd�dFdG�Z.dHdI�Z/d\e'd�dKdL�Z0dMdN�Z1dOdP�Z2dQdR�Z3dSdT�Z4dUdV�Z5e6d]dd�dWdX��Z7e+Z8e-Z9e/Z:dS)^�ParseResultsaStructured parse results, to provide multiple means of access to
    the parsed data:

    - as a list (``len(results)``)
    - by list index (``results[0], results[1]``, etc.)
    - by attribute (``results.<results_name>`` - see :class:`ParserElement.set_results_name`)

    Example::

        integer = Word(nums)
        date_str = (integer.set_results_name("year") + '/'
                    + integer.set_results_name("month") + '/'
                    + integer.set_results_name("day"))
        # equivalent form:
        # date_str = (integer("year") + '/'
        #             + integer("month") + '/'
        #             + integer("day"))

        # parse_string returns a ParseResults object
        result = date_str.parse_string("1999/12/31")

        def test(s, fn=repr):
            print("{} -> {}".format(s, fn(eval(s))))
        test("list(result)")
        test("result[0]")
        test("result['month']")
        test("result.day")
        test("'month' in result")
        test("'minutes' in result")
        test("result.dump()", str)

    prints::

        list(result) -> ['1999', '/', '12', '/', '31']
        result[0] -> '1999'
        result['month'] -> '12'
        result.day -> '31'
        'month' in result -> True
        'minutes' in result -> False
        result.dump() -> ['1999', '/', '12', '/', '31']
        - day: 31
        - month: 12
        - year: 1999
    N�r.�_null_values)�_name�_parent�
_all_names�_modal�_toklist�_tokdict�__weakref__c@seZdZdZddd�ZdS)zParseResults.Lista�
        Simple wrapper class to distinguish parsed list results that should be preserved
        as actual Python lists, instead of being converted to :class:`ParseResults`:

            LBRACK, RBRACK = map(pp.Suppress, "[]")
            element = pp.Forward()
            item = ppc.integer
            element_list = LBRACK + pp.delimited_list(element) + RBRACK

            # add parse actions to convert from ParseResults to actual Python collection types
            def as_python_list(t):
                return pp.ParseResults.List(t.as_list())
            element_list.add_parse_action(as_python_list)

            element <<= item | element_list

            element.run_tests('''
                100
                [2,3,4]
                [[2, 1],3,4]
                [(2, 1),3,4]
                (2,3,4)
                ''', post_parse=lambda s, r: (r[0], type(r[0])))

        prints:

            100
            (100, <class 'int'>)

            [2,3,4]
            ([2, 3, 4], <class 'list'>)

            [[2, 1],3,4]
            ([[2, 1], 3, 4], <class 'list'>)

        (Used internally by :class:`Group` when `aslist=True`.)
        NcCs8|durg}t|t�s.td�|jt|�j���t�|�S)Nz.{} may only be constructed with a list, not {})�
isinstance�list�	TypeError�formatr�type�__new__)�clsZ	containedrrrr1|s
��zParseResults.List.__new__)N)rrr �__doc__r1rrrr�ListUs&r4cKs�t|t�r|St�|�}d|_d|_t�|_|dur<g|_n<t|t	t
f�rpt|tj�rd|dd�gnt	|�|_n|g|_t�|_
|Sr
)r,r"�objectr1r%r&�setr'r)r-�_generator_typer4�dictr*)r2�toklist�name�kwargsrrrrr1�s 


��zParseResults.__new__Tc
Cs�||_|dur�|dkr�||t�r(t|�}|s4|h|_||_||jvr�||ttf�rX|g}|r�||t�r|t	t|j
�d�||<nt	t|d�d�||<|||_nBz|d||<Wn0ttt
fy�||ur�|||<n||_Yn0dS)Nr#r)r(�int�strr'r%r$r	r0r"rr)�KeyErrorr.�
IndexError)rr9r:�asListZmodalr,rrrr�s2



�
�
zParseResults.__init__cCsPt|ttf�r|j|S||jvr4|j|ddStdd�|j|D��SdS)N���rcSsg|]}|d�qS)rr�r�vrrr�
<listcomp>�rz,ParseResults.__getitem__.<locals>.<listcomp>)r,r<�slicer)r'r*r"rrrrr�s


zParseResults.__getitem__cCs�||t�r0|j�|t��|g|j|<|d}nD||ttf�rN||j|<|}n&|j�|t��t|d�g|j|<|}||t�r�t|�|_	dSr)
rr*�getr-r<rEr)r"�wkrefr&)r�krCr,�subrrr�__setitem__�s


�
zParseResults.__setitem__c
Cs�t|ttf�r�t|j�}|j|=t|t�rH|dkr:||7}t||d�}tt|�|���}|��|j	�
�D]>\}}|D]0}t|�D]"\}\}}	t||	|	|k�||<q�qxqln|j	|=dS)Nr�)
r,r<rE�lenr)r-�range�indices�reverser*�items�	enumerater)
rrZmylenZremovedr:�occurrences�jrH�value�positionrrr�__delitem__�s 

�zParseResults.__delitem__)�returncCs
||jvSr
)r*)rrHrrr�__contains__�szParseResults.__contains__cCs
t|j�Sr
)rLr)rrrr�__len__�szParseResults.__len__cCs|jp
|jSr
)r)r*rrrr�__bool__�szParseResults.__bool__cCs
t|j�Sr
��iterr)rrrr�__iter__�szParseResults.__iter__cCst|jddd��S)NrAr[rrrr�__reversed__�szParseResults.__reversed__cCs
t|j�Sr
)r\r*rrrr�keys�szParseResults.keyscs�fdd����D�S)Nc3s|]}�|VqdSr
r�rrHrrrrrz&ParseResults.values.<locals>.<genexpr>�r_rrrr�valuesszParseResults.valuescs�fdd����D�S)Nc3s|]}|�|fVqdSr
rr`rrrrrz%ParseResults.items.<locals>.<genexpr>rarrrrrPszParseResults.itemscCs
t|j�S)z�
        Since ``keys()`` returns an iterator, this method is helpful in bypassing
        code that looks for the existence of any defined results names.)�boolr*rrrr�haskeysszParseResults.haskeyscOs�|s
dg}|��D],\}}|dkr0|d|f}qtd�|���qt|dt�sft|�dksf|d|vr�|d}||}||=|S|d}|SdS)a�
        Removes and returns item at specified index (default= ``last``).
        Supports both ``list`` and ``dict`` semantics for ``pop()``. If
        passed no argument or an integer argument, it will use ``list``
        semantics and pop tokens from the list of parsed tokens. If passed
        a non-integer argument (most likely a string), it will use ``dict``
        semantics and pop the corresponding value from any defined results
        names. A second default return value argument is supported, just as in
        ``dict.pop()``.

        Example::

            numlist = Word(nums)[...]
            print(numlist.parse_string("0 123 321")) # -> ['0', '123', '321']

            def remove_first(tokens):
                tokens.pop(0)
            numlist.add_parse_action(remove_first)
            print(numlist.parse_string("0 123 321")) # -> ['123', '321']

            label = Word(alphas)
            patt = label("LABEL") + OneOrMore(Word(nums))
            print(patt.parse_string("AAB 123 321").dump())

            # Use pop() in a parse action to remove named result (note that corresponding value is not
            # removed from list form of results)
            def remove_LABEL(tokens):
                tokens.pop("LABEL")
                return tokens
            patt.add_parse_action(remove_LABEL)
            print(patt.parse_string("AAB 123 321").dump())

        prints::

            ['AAB', '123', '321']
            - LABEL: AAB

            ['AAB', '123', '321']
        rA�defaultrz-pop() got an unexpected keyword argument {!r}rKN)rPr.r/r,r<rL)rrr;rHrC�index�retZdefaultvaluerrr�pops(�&zParseResults.popcCs||vr||S|SdS)a^
        Returns named result matching the given key, or if there is no
        such name, then returns the given ``default_value`` or ``None`` if no
        ``default_value`` is specified.

        Similar to ``dict.get()``.

        Example::

            integer = Word(nums)
            date_str = integer("year") + '/' + integer("month") + '/' + integer("day")

            result = date_str.parse_string("1999/12/31")
            print(result.get("year")) # -> '1999'
            print(result.get("hour", "not specified")) # -> 'not specified'
            print(result.get("hour")) # -> None
        Nr)r�keyZ
default_valuerrrrFFszParseResults.getcCsR|j�||�|j��D]4\}}t|�D]"\}\}}t||||k�||<q(qdS)a;
        Inserts new element at location index in the list of parsed tokens.

        Similar to ``list.insert()``.

        Example::

            numlist = Word(nums)[...]
            print(numlist.parse_string("0 123 321")) # -> ['0', '123', '321']

            # use a parse action to insert the parse location in the front of the parsed results
            def insert_locn(locn, tokens):
                tokens.insert(0, locn)
            numlist.add_parse_action(insert_locn)
            print(numlist.parse_string("0 123 321")) # -> [0, '0', '123', '321']
        N)r)�insertr*rPrQr)rrfZ
ins_stringr:rRrHrTrUrrrrj]s�zParseResults.insertcCs|j�|�dS)a
        Add single element to end of ``ParseResults`` list of elements.

        Example::

            numlist = Word(nums)[...]
            print(numlist.parse_string("0 123 321")) # -> ['0', '123', '321']

            # use a parse action to compute the sum of the parsed integers, and add it to the end
            def append_sum(tokens):
                tokens.append(sum(map(int, tokens)))
            numlist.add_parse_action(append_sum)
            print(numlist.parse_string("0 123 321")) # -> ['0', '123', '321', 444]
        N)r)�append)r�itemrrrrkvszParseResults.appendcCs&t|t�r|�|�n|j�|�dS)a!
        Add sequence of elements to end of ``ParseResults`` list of elements.

        Example::

            patt = OneOrMore(Word(alphas))

            # use a parse action to append the reverse of the matched strings, to make a palindrome
            def make_palindrome(tokens):
                tokens.extend(reversed([t[::-1] for t in tokens]))
                return ''.join(tokens)
            patt.add_parse_action(make_palindrome)
            print(patt.parse_string("lskdj sdlkjf lksd")) # -> 'lskdjsdlkjflksddsklfjkldsjdksl'
        N)r,r"�__iadd__r)�extend)rZitemseqrrrrn�s
zParseResults.extendcCs|jdd�=|j��dS)z7
        Clear all elements and results names.
        N)r)r*�clearrrrrro�szParseResults.clearcCs6z
||WSty0|�d�r*t|��YdS0dS)N�__r#)r>�
startswith�AttributeError)rr:rrr�__getattr__�s

zParseResults.__getattr__cCs|��}||7}|Sr
)�copy)r�otherrgrrr�__add__�szParseResults.__add__cs�|jrjt|j���fdd��|j��}�fdd�|D�}|D],\}}|||<t|dt�r<t|�|d_q<|j|j7_|j|jO_|S)Ncs|dkr�S|�Srr)�a)�offsetrr�<lambda>�rz'ParseResults.__iadd__.<locals>.<lambda>c	s4g|],\}}|D]}|t|d�|d��f�qqS)rrK)r)rrH�vlistrC)�	addoffsetrrrD�s�z)ParseResults.__iadd__.<locals>.<listcomp>r)	r*rLr)rPr,r"rGr&r')rruZ
otheritemsZotherdictitemsrHrCr)r{rxrrm�s


�zParseResults.__iadd__cCs&t|t�r|dkr|��S||SdSr)r,r<rt)rrurrr�__radd__�szParseResults.__radd__cCsd�t|�j|j|���S)Nz{}({!r}, {}))r/r0rr)�as_dictrrrr�__repr__�szParseResults.__repr__cCsdd�dd�|jD��dS)N�[z, css(|] }t|t�rt|�nt|�VqdSr
)r,r"r=�repr)rrrrrr�s�z'ParseResults.__str__.<locals>.<genexpr>�])�joinr)rrrr�__str__�s
����zParseResults.__str__cCsLg}|jD]<}|r |r |�|�t|t�r8||��7}q
|�t|��q
|Sr
)r)rkr,r"�
_asStringListr=)r�sep�outrlrrrr��s


zParseResults._asStringListcCsdd�|jD�S)a{
        Returns the parse results as a nested list of matching tokens, all converted to strings.

        Example::

            patt = OneOrMore(Word(alphas))
            result = patt.parse_string("sldkj lsdkj sldkj")
            # even though the result prints in string-like form, it is actually a pyparsing ParseResults
            print(type(result), result) # -> <class 'pyparsing.ParseResults'> ['sldkj', 'lsdkj', 'sldkj']

            # Use as_list() to create an actual list
            result_list = result.as_list()
            print(type(result_list), result_list) # -> <class 'list'> ['sldkj', 'lsdkj', 'sldkj']
        cSs"g|]}t|t�r|��n|�qSr)r,r"�as_list)r�resrrrrD�s�z(ParseResults.as_list.<locals>.<listcomp>)r)rrrrr��s�zParseResults.as_listcs&�fdd��t�fdd�|��D��S)a�
        Returns the named parse results as a nested dictionary.

        Example::

            integer = Word(nums)
            date_str = integer("year") + '/' + integer("month") + '/' + integer("day")

            result = date_str.parse_string('12/31/1999')
            print(type(result), repr(result)) # -> <class 'pyparsing.ParseResults'> (['12', '/', '31', '/', '1999'], {'day': [('1999', 4)], 'year': [('12', 0)], 'month': [('31', 2)]})

            result_dict = result.as_dict()
            print(type(result_dict), repr(result_dict)) # -> <class 'dict'> {'day': '1999', 'year': '12', 'month': '31'}

            # even though a ParseResults supports dict-like access, sometime you just need to have a dict
            import json
            print(json.dumps(result)) # -> Exception: TypeError: ... is not JSON serializable
            print(json.dumps(result.as_dict())) # -> {"month": "31", "day": "1999", "year": "12"}
        cs4t|t�r,|��r|��S�fdd�|D�S|SdS)Ncsg|]}�|��qSrrrB��to_itemrrrD
rz9ParseResults.as_dict.<locals>.to_item.<locals>.<listcomp>)r,r"rdr}��objr�rrr�s
"z%ParseResults.as_dict.<locals>.to_itemc3s|]\}}|�|�fVqdSr
r�rrHrCr�rrrrz'ParseResults.as_dict.<locals>.<genexpr>)r8rPrrr�rr}�szParseResults.as_dictcCs:t|j�}|j��|_|j|_|j|jO_|j|_|S)zG
        Returns a new copy of a :class:`ParseResults` object.
        )r"r)r*rtr&r'r%)rrgrrrrts
zParseResults.copycs�|jr|jS|jr6|����fdd�}�r2||�SdSt|�dkr�t|j�dkr�tt|j����dddvr�tt|j����SdSdS)a
        Returns the results name for this token expression. Useful when several
        different expressions might match at a particular location.

        Example::

            integer = Word(nums)
            ssn_expr = Regex(r"\d\d\d-\d\d-\d\d\d\d")
            house_number_expr = Suppress('#') + Word(nums, alphanums)
            user_data = (Group(house_number_expr)("house_number")
                        | Group(ssn_expr)("ssn")
                        | Group(integer)("age"))
            user_info = OneOrMore(user_data)

            result = user_info.parse_string("22 111-22-3333 #221B")
            for item in result:
                print(item.get_name(), ':', item[0])

        prints::

            age : 22
            ssn : 111-22-3333
            house_number : 221B
        cst�fdd��j��D�d�S)Nc3s,|]$\}}|D]\}}�|ur|VqqdSr
r)rrHrzrC�loc�rIrrr>s�z@ParseResults.get_name.<locals>.find_in_parent.<locals>.<genexpr>)�nextr*rPr���parr�r�find_in_parent<s
��z-ParseResults.get_name.<locals>.find_in_parentNrKr)rrA)r%r&rLr*r�r\rbr_)rr�rr�r�get_names
���zParseResults.get_namercCslg}d}|�|r |t|���nd�|�rb|��r�tdd�|��D��}|D]x\}}	|rd|�|�|�d�|d||��t|	t�r�|	r�|�|	j	||||dd��q�|�t|	��qN|�t
|	��qNtd	d�|D���rb|}	t|	�D]x\}
}t|t��r6|�d
�|d||
|d|d|j	||||dd���q�|�d|d||
|d|dt|�f�q�d�
|�S)aG
        Diagnostic method for listing out the contents of
        a :class:`ParseResults`. Accepts an optional ``indent`` argument so
        that this string can be embedded in a nested display of other data.

        Example::

            integer = Word(nums)
            date_str = integer("year") + '/' + integer("month") + '/' + integer("day")

            result = date_str.parse_string('12/31/1999')
            print(result.dump())

        prints::

            ['12', '/', '31', '/', '1999']
            - day: 1999
            - month: 31
            - year: 12
        �
r#css|]\}}t|�|fVqdSr
)r=r�rrrrlrz$ParseResults.dump.<locals>.<genexpr>z
{}{}- {}: z  rK)�indent�full�include_list�_depthcss|]}t|t�VqdSr
)r,r")r�vvrrrrrz
{}{}[{}]:
{}{}{}z
%s%s[%d]:
%s%s%s)rkr=r�rd�sortedrPr/r,r"�dumpr��anyrQr�)rr�r�r�r�r��NLrPrHrCrr�rrrr�Qsj

��	
���
���zParseResults.dumpcOs tj|��g|�Ri|��dS)a%
        Pretty-printer for parsed results as a list, using the
        `pprint <https://docs.python.org/3/library/pprint.html>`_ module.
        Accepts additional positional or keyword args as defined for
        `pprint.pprint <https://docs.python.org/3/library/pprint.html#pprint.pprint>`_ .

        Example::

            ident = Word(alphas, alphanums)
            num = Word(nums)
            func = Forward()
            term = ident | num | Group('(' + func + ')')
            func <<= ident + Group(Optional(delimited_list(term)))
            result = func.parse_string("fna a,b,(fnb c,d,200),100")
            result.pprint(width=40)

        prints::

            ['fna',
             ['a',
              'b',
              ['(', 'fnb', ['c', 'd', '200'], ')'],
              '100']]
        N)�pprintr�)rrr;rrrr��szParseResults.pprintcCs.|j|j��|jdur|��p d|j|jffSr
)r)r*rtr&r'r%rrrrr�s��zParseResults.__getstate__cCs>|\|_\|_}}|_t|�|_|dur4t|�|_nd|_dSr
)r)r*r%r6r'rGr&)r�stater�ZinAccumNamesrrrr�s

zParseResults.__setstate__cCs|j|jfSr
)r)r%rrrr�__getnewargs__�szParseResults.__getnewargs__cCstt|��t|���Sr
)�dirr0r-r_rrrr�__dir__�szParseResults.__dir__cCsrdd�}|g�}|��D]>\}}t|t�r>||j||d�7}q|||g|||�d�7}q|durn||g|d�}|S)z�
        Helper classmethod to construct a ``ParseResults`` from a ``dict``, preserving the
        name-value relations as results names. If an optional ``name`` argument is
        given, a nested ``ParseResults`` will be returned.
        cSs2zt|�Wnty YdS0t|t�SdS)NF)r\�	Exceptionr,r	r�rrr�is_iterable�s
z+ParseResults.from_dict.<locals>.is_iterable)r:)r:r@N)rPr,r�	from_dict)r2rur:r�rgrHrCrrrr��s
zParseResults.from_dict)NN)N)r#)r#TTr)N);rrr r3r$rr�__annotations__r!r-r4r1r,rrrJrVrcrXr<rYrZrr]r^r_rbrPrdrhrFrjrkrnrorsrvrmr|r=r~r�r�r�r8r}rtr�r�r�rrr�r��classmethodr�r@ZasDict�getNamerrrrr"s^
-
3

�
 	:


3Pr")�collections.abcrrrrr��weakrefrrG�typingrrr=�bytesr	r0r�r7rr"�registerrrrr�<module>s_


Youez - 2016 - github.com/yon3zu
LinuXploit