CasperSecurity

Current Path : /lib/python3/dist-packages/pyrsistent/__pycache__/
Upload File :
Current File : //lib/python3/dist-packages/pyrsistent/__pycache__/_pclass.cpython-310.pyc

o

���a�%�@s�ddlmZmZmZmZddlmZmZmZm	Z	m
Z
mZddlm
Z
dd�ZGdd�de�Ze�Zdd	�ZGd
d�deed�ZGd
d�de�ZdS)�)�InvariantException�CheckedType�_restore_pickle�store_invariants)�
set_fields�
check_type�is_field_ignore_extra_complaint�PFIELD_NO_INITIAL�	serialize�check_global_invariants��	transformcCst|�dko|dtkS)N�r)�lenr)�bases�r�4/usr/lib/python3/dist-packages/pyrsistent/_pclass.py�
_is_pclasssrcseZdZ�fdd�Z�ZS)�
PClassMetacsht||dd�t||dd�dtdd�|dD��|d<t|�r)|dd	7<tt|��||||�S)
N�_pclass_fields)�name�_pclass_invariants�
__invariant__)�_pclass_frozencss�|]}|VqdS�Nr��.0�keyrrr�	<genexpr>s�z%PClassMeta.__new__.<locals>.<genexpr>�	__slots__)�__weakref__)rr�tupler�superr�__new__)�mcsrr�dct��	__class__rrr#
szPClassMeta.__new__)�__name__�
__module__�__qualname__r#�
__classcell__rrr&rrsrcCs>t||||�|�|�\}}|s|�|�dSt|||�dSr)r�	invariant�append�setattr)�cls�fieldr�value�result�invariant_errors�is_ok�
error_coderrr�_check_and_set_attrs
r6cs�eZdZdZ�fdd�Zdd�Zed"dd	��Zd#d
d�Zdd
�Z	dd�Z
dd�Zdd�Z�fdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zd d!�Z�ZS)$�PClassa�
    A PClass is a python class with a fixed set of specified fields. PClasses are declared as python classes inheriting
    from PClass. It is defined the same way that PRecords are and behaves like a PRecord in all aspects except that it
    is not a PMap and hence not a collection but rather a plain Python object.


    More documentation and examples of PClass usage is available at https://github.com/tobgu/pyrsistent
    csLtt|��|�}|�dd�}|�dd�}g}g}|j��D]a\}}||vrV|dus-||vrEtt||�r=|j|||d�}	n|�||�}	n||}	t||||	||�||=q|j	t
urqt|j	�rd|�	�n|j	}
t||||
||�q|jr~|�
d�|j|��q|s�|r�tt|�t|�d��|r�td�d�|�|j���t||j�d|_|S)	N�_factory_fields�ignore_extra)r9z{0}.{1}zField invariant failedz0'{0}' are not among the specified fields for {1}�, T)r"r7r#�popr�itemsr�factoryr6�initialr	�callable�	mandatoryr-�formatr(rr!�AttributeError�joinrrr)r/�kwargsr2�factory_fieldsr9�missing_fieldsr3rr0r1r>r&rrr#.s>
���zPClass.__new__cOs`|r
|d||d<t|�}|jD]}||vr%t||t�}|tur%|||<q|jdd|i|��S)a
        Set a field in the instance. Returns a new instance with the updated value. The original instance remains
        unmodified. Accepts key-value pairs or single string representing the field name and a value.

        >>> from pyrsistent import PClass, field
        >>> class AClass(PClass):
        ...     x = field()
        ...
        >>> a = AClass(x=1)
        >>> a2 = a.set(x=2)
        >>> a3 = a.set('x', 3)
        >>> a
        AClass(x=1)
        >>> a2
        AClass(x=2)
        >>> a3
        AClass(x=3)
        rrr8Nr)�setr�getattr�_MISSING_VALUEr')�self�argsrDrErr1rrrrGRs
�z
PClass.setNFcs:t�|�r�S|r�fdd�|jD��|d||d����S)a:
        Factory method. Will create a new PClass of the current type and assign the values
        specified in kwargs.

        :param ignore_extra: A boolean which when set to True will ignore any keys which appear in kwargs that are not
                             in the set of fields on the PClass.
        csi|]}|�vr|�|�qSrr)r�k�rDrr�
<dictcomp>sz!PClass.create.<locals>.<dictcomp>)r8r9Nr)�
isinstancer)r/rDr8r9rrMr�creaters

	z
PClass.createcCs@i}|jD]}t||t�}|turt|j|j||�||<q|S)z�
        Serialize the current PClass using custom serializer functions for fields where
        such have been supplied.
        )rrHrIr
�
serializer)rJrAr2rr1rrrr
�s
�zPClass.serializecGs
t||�S)aT
        Apply transformations to the currency PClass. For more details on transformations see
        the documentation for PMap. Transformations on PClasses do not support key matching
        since the PClass is not a collection. Apart from that the transformations available
        for other persistent types work as expected.
        r)rJ�transformationsrrrr
�s
zPClass.transformcCs>t||j�r|jD]}t||t�t||t�krdSq	dStS)NFT)rOr'rrHrI�NotImplemented)rJ�otherrrrr�__eq__�s
�z
PClass.__eq__cCs
||kSrr)rJrTrrr�__ne__��
z
PClass.__ne__cstt�fdd��jD���S)Nc3s �|]}|t�|t�fVqdSr)rHrIr�rJrrr�s�z"PClass.__hash__.<locals>.<genexpr>)�hashr!rrXrrXr�__hash__�szPClass.__hash__cs2t|dd�rtd�||���tt|��||�dS)NrFz'Can't set attribute, key={0}, value={1})rHrBrAr"r7�__setattr__�rJrr1r&rrr[�szPClass.__setattr__cCstd�|���)Nz-Can't delete attribute, key={0}, use remove())rBrA)rJrrrr�__delattr__��zPClass.__delattr__cCs0i}|jD]}t||t�}|tur|||<q|Sr)rrHrI)rJr2rr1rrr�_to_dict�s
�zPClass._to_dictcCs(d�|jjd�dd�|����D���S)Nz{0}({1})r:css$�|]
\}}d�|t|��VqdS)z{0}={1}N)rA�repr)rrL�vrrrr�s�"z"PClass.__repr__.<locals>.<genexpr>)rAr'r(rCr_r<rXrrr�__repr__�s
�zPClass.__repr__cs&t�fdd��jD��}t�j|ffS)Nc3s(�|]}t�|�r|t�|�fVqdSr)�hasattrrHrrXrrr�s�&z$PClass.__reduce__.<locals>.<genexpr>)�dictrrr')rJ�datarrXr�
__reduce__�szPClass.__reduce__cCst||���S)z5
        Returns an evolver for this object.
        )�_PClassEvolverr_rXrrr�evolver�szPClass.evolvercCs|��}||=|��S)z�
        Remove attribute given by name from the current instance. Raises AttributeError if the
        attribute doesn't exist.
        )rh�
persistent)rJrrhrrr�remove�sz
PClass.remove�NFr)r(r)r*�__doc__r#rG�classmethodrPr
r
rUrVrZr[r]r_rbrfrhrjr+rrr&rr7%s$$ 

	
	r7)�	metaclasscs`eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
�fdd�Zdd�Z�Z
S)rg)�_pclass_evolver_original�_pclass_evolver_data�_pclass_evolver_data_is_dirtyr8cCs||_||_d|_t�|_dSrk)rorprqrGr8)rJ�original�initial_dictrrr�__init__�sz_PClassEvolver.__init__cCs
|j|Sr)rp�rJ�itemrrr�__getitem__�rWz_PClassEvolver.__getitem__cCs2|j�|t�|ur||j|<|j�|�d|_|S�NT)rp�getrIr8�addrqr\rrrrG�s

z_PClassEvolver.setcCs|�||�dSr)rGr\rrr�__setitem__�sz_PClassEvolver.__setitem__cCs0||jvr|j|=|j�|�d|_|St|��rx)rpr8�discardrqrBrurrrrj�s
z_PClassEvolver.removecCs|�|�dSr)rjrurrr�__delitem__�r^z_PClassEvolver.__delitem__cCs&|jr|jjdd|ji|j��S|jS)Nr8r)rqror'r8rprXrrrri�s
�z_PClassEvolver.persistentcs0||jvr
|�||�dStt|��||�dSr)rrGr"rgr[r\r&rrr[�s
z_PClassEvolver.__setattr__cCs||Srrrurrr�__getattr__sz_PClassEvolver.__getattr__)r(r)r*rrtrwrGr{rjr}rir[r~r+rrr&rrg�s	rgN)�pyrsistent._checked_typesrrrr�pyrsistent._field_commonrrrr	r
r�pyrsistent._transformationsr
r�typer�objectrIr6r7rgrrrr�<module>s 
	1
Hacker Blog, Shell İndir, Sql İnjection, XSS Attacks, LFI Attacks, Social Hacking, Exploit Bot, Proxy Tools, Web Shell, PHP Shell, Alfa Shell İndir, Hacking Training Set, DDoS Script, Denial Of Service, Botnet, RFI Attacks, Encryption
Telegram @BIBIL_0DAY