Viewing File: /opt/imunify360/venv/lib/python3.11/site-packages/pyrsistent/__pycache__/_pvector.cpython-311.pyc



]jXddlmZmZddlmZmZddlmZddlZddl	m
Z
dZdZedz
Z
ee
Zd	Zd
ZGddeZGd
deZedeggZeeejeejeddZ	ddlZejdreZn,ddlmZeeen
#e$reZYnwxYwdZdS))abstractmethodABCMeta)SequenceHashable)IntegralN	transformcFt|dS)N1)bincount)vals s/builddir/build/BUILD/imunify360-venv-2.6.3/opt/imunify360/venv/lib/python3.11/site-packages/pyrsistent/_pvector.py	_bitcountrss88>># c||t|tr|n|SN)tolist
isinstancePVector)votheroperators   rcompare_pvectorrs88AHHJJ*UG2L2L WRWXXXrc*||St||Sr)slice)indexstops  r_index_or_slicer!s|rc0eZdZdZdZfdZdZdZdZdZ	dZ
d	Zd
ZdZ
dZd
ZdZdZdZeZdZdZdZdZdZdZdZGddeZdZdZdZe dZ!dZ"dZ#d Z$d!Z%d"Z&d#Z'd$Z(d%Z)d&Z*d'Z+d+d)Z,d*Z-xZ.S),
PythonPVectorzd
    Support structure for PVector that implements structural sharing for vectors using a trie.
    )_count_shift_root_tail_tail_offset__weakref__ctt||}||_||_||_||_|jt|jz
|_|Sr)	superr#__new__r$r%r&r'lenr()clsr
shiftroottailself	__class__s      rr,zPythonPVector.__new__!sZ]C((0055

!K#dj//9rc|jSr)r$r2s r__len__zPythonPVector.__len__,s
{rc0t|trI|j|j	|j|St
||S|dkr
||jz
}t
|||tzSNr)rrstartr step_EMPTY_PVECTORextendrr$r#	_node_forBIT_MASKr2rs  r__getitem__zPythonPVector.__getitem__/seU##	?{"uz'9ej>P"((u)=>>>199T[ E&&tU33EH4DEErc,||Sr)r<r2rs  r__add__zPythonPVector.__add__?s{{5!!!rcjdt|S)Nzpvector({0}))formatstrrr5s r__repr__zPythonPVector.__repr__Bs&$$S%7%7888rc*|Sr)rGr5s r__str__zPythonPVector.__str__Es}}rcDt|Sr)iterrr5s r__iter__zPythonPVector.__iter__HsDKKMM"""rc.||Sr)__eq__rBs  r__ne__zPythonPVector.__ne__Ms;;u%%%%rc||upBt|do2|jt|kot||tjS)Nr6)hasattrr$r-rreqrBs  rrNzPythonPVector.__eq__Ps_u}H	!:!:!Xt{cRWjj?X!H^mnrty|D|G_H_H	Hrc8t||tjSr)rrgtrBs  r__gt__zPythonPVector.__gt__StUHK888rc8t||tjSr)rrltrBs  r__lt__zPythonPVector.__lt__VrVrc8t||tjSr)rrgerBs  r__ge__zPythonPVector.__ge__YrVrc8t||tjSr)rrlerBs  r__le__zPythonPVector.__le__\rVrc|dks	|turtS|dkr|St||zSNrr)r;r<rr2timess  r__mul__zPythonPVector.__mul___sJA:://!!A::K$$UT[[]]%:;;;rc|r(|tz}|D]}||||dS||dSr)SHIFT
_fill_listr<)r2noder/the_listns     rrgzPythonPVector._fill_listjs_	"UNE
4
45(3333
4
4
OOD!!!!!rcg}||j|j|||j|S)zK
        The fastest way to convert the vector into a python list.
        )rgr&r%r<r')r2ris  rrzPythonPVector.tolistrs<
DK:::
###rcDt|S)z8
        Returns the content as a python tuple.
        )tuplerr5s r_totuplezPythonPVector._totuple{sT[[]]###rcDt|Sr)hashrnr5s r__hash__zPythonPVector.__hash__sDMMOO$$$rc"t||Srrr2transformationss  rr	zPythonPVector.transforms///rc:t|ffSr)pvectorrr5s r
__reduce__zPythonPVector.__reduce__s(((rct|dzrtd|}tdt|dD]}||dz|||<|S)Nz)mset expected an even number of argumentsrr)r-	TypeErrorevolverrange
persistent)r2argsr{is    rmsetzPythonPVector.msets}t99q=	IGHHH,,..q#d))Q''	)	)A#AaCyGDG!!###rc`eZdZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZ
dZd
ZdZdS)PythonPVector.Evolver)	r$r%r&r'r(_dirty_nodes_extra_tail
_cached_leafs
_orig_pvectorc0||dSr)_resetr2rs  r__init__zPythonPVector.Evolver.__init__sKKNNNNNrct|ts$tdt|jz|dkr||jt
|jzz
}|j|cxkr |jt
|jzkrnn|j||jz
St	|||tzS)N-'%s' object cannot be interpreted as an indexr)rrrztype__name__r$r-rr#r=r>r?s  rr@z!PythonPVector.Evolver.__getitem__seX..
h ORVW\R]R]Rf fgggqyys4+;'<'<<<{eIIIIdkC8H4I4I&IIIIII'(;<< **4778HIIrc|j|_|j|_|j|_|j|_|j|_i|_i|_g|_||_dSr)	r$r%r&r'r(rrrrrs  rrzPythonPVector.Evolver._resetsV(DK(DKDJDJ !D "D!#D!D!"Drc:|j||Sr)rappend)r2elements  rrzPythonPVector.Evolver.appends##G,,,Krc:|j||Sr)rr<)r2iterables  rr<zPythonPVector.Evolver.extends##H---Krc|||<|Sr)r2rrs   rsetzPythonPVector.Evolver.setsDKKrct|ts$tdt|jz|dkr||jt
|jzz
}d|cxkr|jkrnn|j	|tz	}|r|||tz<dS||jkr{t|j|jvrLt!|j|_d|jt|j<|j|j|tz	<||j|tz<dS||j|j|||_dS|j|cxkr |jt
|jzkrnn||j||jz
<dS||jt
|jzkr|j|dSt+d|)NrrTIndex out of range: )rrrzrrr$r-rrgetrfr>r(idr'rlist_do_setr%r&r
IndexError)r2rrrhs    r__setitem__z!PythonPVector.Evolver.__setitem__seX..
h ORVW\R]R]Rf fgggqyys4+;'<'<<<E''''DK''''')--eun==	S-0D)***d///$*~~T->>>%)$*%5%5
<@)"TZ..9=AZ*5E>:36DJux/000!%dk4:uc!R!RDJJJKKKKc$:J6K6K(KKKKKK8; !4555$+D,<(=(==== '',,,,, jUU!DEEErc<t||jvr|}n&t|}d|jt|<|dkr |||tz<||j|t
z	<n6||z	tz}||t
z
||||||<|S)NTr)rrrr>rrfrr2levelrhrrret	sub_indexs       rrzPythonPVector.Evolver._do_sets$xx4,,,4jj-1!"S''*zz$'AL!14"1:..%Z83	!%eemT)_aQT!U!UIJrc||=|Srrr?s  rdeletezPythonPVector.Evolver.deletesUKrc
|jrst|j|j|j|j}||j|	t||_|j|=dSr)rr#r$r%r&r'rr<rrr;)r2keyls   r__delitem__z!PythonPVector.Evolver.__delitem__st!
%!$+t{DJ
SSZZ\\)***N+++#$  %%%rc|j}|rSt|j|j|j|j|j}|	||Sr)
ris_dirtyr#r$r%r&r'r<rr)r2results  rr}z PythonPVector.Evolver.persistents^'F}}
$&t{DKTZXX__`d`pqqF###Mrc:|jt|jzSr)r$r-rr5s rr6zPythonPVector.Evolver.__len__s;T%5!6!666rc8t|jp|jSr)boolrrr5s rrzPythonPVector.Evolver.is_dirtys)=T-=>>>rN)r
__module____qualname__	__slots__rr@rrr<rrrrrr}r6rrrrEvolverrsF				
	J
	J
	J		#		#		#										F	F	F4			 				&	&	&				7	7	7	?	?	?	?	?rrc6t|Sr)r#rr5s rr{zPythonPVector.evolvers$$T***rc
>t|ts$tdt|jz|dkr
||jz
}d|cxkr|jkrnn||jkrBt|j}|||tz<t|j|j|j|St|j|j|
|j|j|||jS||jkr||Std|)Nrrr)rrrzrrr$r(rr'r>r#r%r&rrr)r2rrnew_tails    rrzPythonPVector.set	s
!X&&	`KdSTggN^^___q55
ADKD%%%
++),X&$T[$+tz8TTT dk4<<UYU_abdg;h;hjnjtuuu;;s###jQQ8999rct|}|dkr|||tz<n6||z	tz}||tz
||||||<|Sr8)rr>rrfrs       rrzPythonPVector._do_set!s]4jjA:: #CHex/I!\\%%-i!SQQC	N
rcd|cxkr|jkrPnnM||jkr|jS|j}t	|jdtD]}|||z	tz}|Std|)Nrr)	r$r(r'r&r|r%rfr>r)pvector_likerrhrs    rr=zPythonPVector._node_for+s''''L''''''L---#))%D|2Av>>
5
5Q%Z834KjQQ8999rc|j}|jtz	d|jzkr2|j||j|jg}|tz
}n&||j|j|j}||fSNr)r%r$rfr&	_new_pathr'
_push_tail)r2	new_shiftnew_roots   r_create_new_rootzPythonPVector._create_new_root9stK	
K5 Q$+%566
DNN4;
$K$KLHIIt{DJ
KKH""rc:t|jtkrMt|j}||t|jdz|j|j|S|	\}}t|jdz|||gSr)
r-r'
BRANCH_FACTORrrr#r$r%r&r)r2rrrrs     rrzPythonPVector.appendEstz??]**DJ''HOOC    q$+tz8TTT#3355)T[1_iC5IIIrcP|dkr|S||tz
|gSr8)rrf)r2rrhs   rrzPythonPVector._new_pathOs+A::Kuu}d3344rcV|\|_|_g|_dSr)rr&r%r'r5s r_mutating_insert_tailz#PythonPVector._mutating_insert_tailUs'"&"7"7"9"9
DK


rctt|jz
}||||z}|j|t|}|xj|z
c_||zSr)rr-r'r<r$)r2offsetsequence
max_delta_lendelta	delta_lens      r_mutating_fill_tailz!PythonPVector._mutating_fill_tailYsd%DJ7
 667
%   JJ	y 	!!rcd}t|}||krM|||}t|jtkr|||kM|jt|jz
|_dSr8)r-rr'rrr$r()r2rrsequence_lens    r_mutating_extendzPythonPVector._mutating_extendas8}}|##--fh??F4:-//**,,,|##
!K#dj//9rct|tr|nt|}|r:||d}||dd|S|Sra)rr#rrrr)r2objr
new_vectors    rr<zPythonPVector.extendksn'sM::ICJJLLLS			QqT**J''!""...rcnt|}|tkr|||S|jdz
|z	tz}t||kr*||tz
|||||<|S|||tz
||S)z
        if parent is leaf, insert node,
        else does it map to an existing child? ->
             node_to_insert = push node one more level
        else alloc new path

        return  node_to_insert placed in copy of parent
        r)rrfrr$r>r-rr)r2rparent	tail_noderrs      rrzPythonPVector._push_tailvs6llE>>JJy!!!JkAo%/8;	v;;""!__UU]F9<MyYYC	NJ

4>>%%-;;<<<
rcH|j|g|Ri|Sr)rrr2valuer~kwargss    rrzPythonPVector.indexs-"t{{}}"5:4:::6:::rcP||Sr)rr
r2rs  rr
zPythonPVector.counts{{}}""5)))rNc|}|t||=t|Sr)rr!r;r<)r2rr rs    rrzPythonPVector.deletes5KKMM
oeT**+$$Q'''rc|}||t|Sr)rremover;r<)r2rrs   rrzPythonPVector.removes2KKMM	$$Q'''rr)/rrr__doc__rr,r6r@rCrGrIrLrOrNrUrYr\r_rd__rmul__rgrrnrqr	rwrobjectrr{rrstaticmethodr=rrrrrrr<rrr
rr
__classcell__)r3s@rr#r#sVI					FFF """999###
&&&HHH999999999999<<<H"""$$$%%%000)))$$$n?n?n?n?n?&n?n?n?`+++:::0::\:
#
#
#JJJ555""":::			.;;;***((((
(((((((rr#c^eZdZdZedZedZedZedZedZ	edZ
edZed	Zed
Z
edZedZed
ZedZeddZedZdS)ra
    Persistent vector implementation. Meant as a replacement for the cases where you would normally
    use a Python list.

    Do not instantiate directly, instead use the factory functions :py:func:`v` and :py:func:`pvector` to
    create an instance.

    Heavily influenced by the persistent vector available in Clojure. Initially this was more or
    less just a port of the Java code for the Clojure vector. It has since been modified and to
    some extent optimized for usage in Python.

    The vector is organized as a trie, any mutating method will return a new vector that contains the changes. No
    updates are done to the original vector. Structural sharing between vectors are applied where possible to save
    space and to avoid making complete copies.

    This structure corresponds most closely to the built in list type and is intended as a replacement. Where the
    semantics are the same (more or less) the same function names have been used but for some cases it is not possible,
    for example assignments.

    The PVector implements the Sequence protocol and is Hashable.

    Inserts are amortized O(1). Random access is log32(n) where n is the size of the vector.

    The following are examples of some common operations on persistent vectors:

    >>> p = v(1, 2, 3)
    >>> p2 = p.append(4)
    >>> p3 = p2.extend([5, 6, 7])
    >>> p
    pvector([1, 2, 3])
    >>> p2
    pvector([1, 2, 3, 4])
    >>> p3
    pvector([1, 2, 3, 4, 5, 6, 7])
    >>> p3[5]
    6
    >>> p.set(1, 99)
    pvector([1, 99, 3])
    >>>
    cdS)z/
        >>> len(v(1, 2, 3))
        3
        Nrr5s rr6zPVector.__len__rcdS)z
        Get value at index. Full slicing support.

        >>> v1 = v(5, 6, 7, 8)
        >>> v1[2]
        7
        >>> v1[1:3]
        pvector([6, 7])
        Nrr?s  rr@zPVector.__getitem__rrcdS)zm
        >>> v1 = v(1, 2)
        >>> v2 = v(3, 4)
        >>> v1 + v2
        pvector([1, 2, 3, 4])
        NrrBs  rrCzPVector.__add__rrcdS)zY
        >>> v1 = v(1, 2)
        >>> 3 * v1
        pvector([1, 2, 1, 2, 1, 2])
        Nrrbs  rrdzPVector.__mul__rrcdS)zo
        >>> v1 = v(1, 2, 3)
        >>> v2 = v(1, 2, 3)
        >>> hash(v1) == hash(v2)
        True
        Nrr5s rrqzPVector.__hash__rrcdS)a~
        Create a new evolver for this pvector. The evolver acts as a mutable view of the vector
        with "transaction like" semantics. No part of the underlying vector i updated, it is still
        fully immutable. Furthermore multiple evolvers created from the same pvector do not
        interfere with each other.

        You may want to use an evolver instead of working directly with the pvector in the
        following cases:

        * Multiple updates are done to the same vector and the intermediate results are of no
          interest. In this case using an evolver may be a more efficient and easier to work with.
        * You need to pass a vector into a legacy function or a function that you have no control
          over which performs in place mutations of lists. In this case pass an evolver instance
          instead and then create a new pvector from the evolver once the function returns.

        The following example illustrates a typical workflow when working with evolvers. It also
        displays most of the API (which i kept small by design, you should not be tempted to
        use evolvers in excess ;-)).

        Create the evolver and perform various mutating updates to it:

        >>> v1 = v(1, 2, 3, 4, 5)
        >>> e = v1.evolver()
        >>> e[1] = 22
        >>> _ = e.append(6)
        >>> _ = e.extend([7, 8, 9])
        >>> e[8] += 1
        >>> len(e)
        9

        The underlying pvector remains the same:

        >>> v1
        pvector([1, 2, 3, 4, 5])

        The changes are kept in the evolver. An updated pvector can be created using the
        persistent() function on the evolver.

        >>> v2 = e.persistent()
        >>> v2
        pvector([1, 22, 3, 4, 5, 6, 7, 8, 10])

        The new pvector will share data with the original pvector in the same way that would have
        been done if only using operations on the pvector.
        Nrr5s rr{zPVector.evolverrrcdS)aY
        Return a new vector with elements in specified positions replaced by values (multi set).

        Elements on even positions in the argument list are interpreted as indexes while
        elements on odd positions are considered values.

        >>> v1 = v(1, 2, 3)
        >>> v1.mset(0, 11, 2, 33)
        pvector([11, 2, 33])
        Nr)r2r~s  rrzPVector.mset$rrcdS)a
        Return a new vector with element at position i replaced with val. The original vector remains unchanged.

        Setting a value one step beyond the end of the vector is equal to appending. Setting beyond that will
        result in an IndexError.

        >>> v1 = v(1, 2, 3)
        >>> v1.set(1, 4)
        pvector([1, 4, 3])
        >>> v1.set(3, 4)
        pvector([1, 2, 3, 4])
        >>> v1.set(-1, 4)
        pvector([1, 2, 4])
        Nr)r2rrs   rrzPVector.set1rrcdS)z
        Return a new vector with val appended.

        >>> v1 = v(1, 2)
        >>> v1.append(3)
        pvector([1, 2, 3])
        Nr)r2rs  rrzPVector.appendBrrcdS)z
        Return a new vector with all values in obj appended to it. Obj may be another
        PVector or any other Iterable.

        >>> v1 = v(1, 2, 3)
        >>> v1.extend([4, 5])
        pvector([1, 2, 3, 4, 5])
        Nr)r2rs  rr<zPVector.extendLrrcdS)z
        Return first index of value. Additional indexes may be supplied to limit the search to a
        sub range of the vector.

        >>> v1 = v(1, 2, 3, 4, 3)
        >>> v1.index(3)
        2
        >>> v1.index(3, 3, 5)
        4
        Nrrs    rrz
PVector.indexWrrcdS)z
        Return the number of times that value appears in the vector.

        >>> v1 = v(1, 4, 3, 4)
        >>> v1.count(4)
        2
        Nrrs  rr
z
PVector.countdrrcdS)a
        Transform arbitrarily complex combinations of PVectors and PMaps. A transformation
        consists of two parts. One match expression that specifies which elements to transform
        and one transformation function that performs the actual transformation.

        >>> from pyrsistent import freeze, ny
        >>> news_paper = freeze({'articles': [{'author': 'Sara', 'content': 'A short article'},
        ...                                   {'author': 'Steve', 'content': 'A slightly longer article'}],
        ...                      'weather': {'temperature': '11C', 'wind': '5m/s'}})
        >>> short_news = news_paper.transform(['articles', ny, 'content'], lambda c: c[:25] + '...' if len(c) > 25 else c)
        >>> very_short_news = news_paper.transform(['articles', ny, 'content'], lambda c: c[:15] + '...' if len(c) > 15 else c)
        >>> very_short_news.articles[0].content
        'A short article'
        >>> very_short_news.articles[1].content
        'A slightly long...'

        When nothing has been transformed the original data structure is kept

        >>> short_news is news_paper
        True
        >>> very_short_news is news_paper
        False
        >>> very_short_news.articles[0] is news_paper.articles[0]
        True
        Nrrss  rr	zPVector.transformnrrNcdS)z
        Delete a portion of the vector by index or range.

        >>> v1 = v(1, 2, 3, 4, 5)
        >>> v1.delete(1)
        pvector([1, 3, 4, 5])
        >>> v1.delete(1, 3)
        pvector([1, 4, 5])
        Nr)r2rr s   rrzPVector.deleterrcdS)z
        Remove the first occurrence of a value from the vector.

        >>> v1 = v(1, 2, 3, 2, 1)
        >>> v2 = v1.remove(1)
        >>> v2
        pvector([2, 3, 2, 1])
        >>> v2.remove(1)
        pvector([2, 3, 2])
        Nrrs  rrzPVector.removerrr)rrrrrr6r@rCrdrqr{rrrr<rr
r	rrrrrrrs''R^		^	^^^--^-^

^
^ ^^

^
^^6			^	

^


rr)	metaclassrc6t|S)z
    Create a new persistent vector containing the elements in iterable.

    >>> v1 = pvector([1, 2, 3])
    >>> v1
    pvector([1, 2, 3])
    )r;r<)rs rpython_pvectorrs  ***rPYRSISTENT_NO_C_EXTENSIONrvc t|S)z
    Create a new persistent vector containing all parameters to this function.

    >>> v1 = v(1, 2, 3)
    >>> v1
    pvector([1, 2, 3])
    r)elementss rrrs8r)r)abcrrcollections.abcrrnumbersrrpyrsistent._transformationsr	rrr>rfrr!rr#rr;registerrosenvironrrvpvectorcrImportErrorrrrr<module>rs!''''''''........111111
1	(YYY@(@(@(@(@(F@(@(@(DDDDDDDDDDNq%R00''++++	
III	z~~122* $$$$$$ggii)))GGGs!A
C//C98C9
Back to Directory File Manager