%PDF- %PDF-
Mini Shell

Mini Shell

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

�

n�9e�%���ddlmZmZmZmZddlmZmZmZm	Z	m
Z
mZddlm
Z
d�ZGd�de�Ze�Zd�ZGd�d	ee�
�ZGd�de�Zy
)�)�InvariantException�CheckedType�_restore_pickle�store_invariants)�
set_fields�
check_type�is_field_ignore_extra_complaint�PFIELD_NO_INITIAL�	serialize�check_global_invariants��	transformc�:�t|�dk(xr|dtk(S)N�r)�lenr)�basess �4/usr/lib/python3/dist-packages/pyrsistent/_pclass.py�
_is_pclassrs���u�:��?�6�u�Q�x�;�6�6�c���eZdZ�fd�Z�xZS)�
PClassMetac����t||d��t||dd�dtd�|dD��z|d<t|�r
|dxxdz
cc<tt
|�||||�S)	N�_pclass_fields)�name�_pclass_invariants�
__invariant__)�_pclass_frozenc3� K�|]}|���y�w�N�)�.0�keys  r�	<genexpr>z%PClassMeta.__new__.<locals>.<genexpr>s����6\�s�s�6\�s��	__slots__)�__weakref__)rr�tupler�superr�__new__)�mcsrr�dct�	__class__s    �rr(zPClassMeta.__new__
sr����3��$4�5���e�%9�?�K�.��6\�c�JZ�F[�6\�1\�\��K���e����� 0�0���Z��-�c�4���D�Dr)�__name__�
__module__�__qualname__r(�
__classcell__�r+s@rrrs���
E�
Errc��t||||�|j|�\}}|s|j|�yt|||�yr)r�	invariant�append�setattr)�cls�fieldr�value�result�invariant_errors�is_ok�
error_codes        r�_check_and_set_attrr<s@���s�E�4��'�����.��E�:�����
�+����e�$rc���eZdZdZ�fd�Zd�Zedd��Zdd�Zd�Z	d�Z
d�Zd	�Z�fd
�Z
d�Zd�Zd
�Zd�Zd�Zd�Z�xZS)�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
    c	���tt|�|�}|jdd�}|jdd�}g}g}|jj�D]�\}}||vr\|�||vr=t
t||�r|j|||��}	n|j||�}	n||}	t||||	||�||=�f|jturBt|j�r|j�n|j}
t||||
||���|js��|jdj|j|����|s|rt!t#|�t#|�d��|r4t%djdj'|�|j���t)||j*�d|_|S)	N�_factory_fields�ignore_extra)rAz{0}.{1}zField invariant failedz0'{0}' are not among the specified fields for {1}�, T)r'r>r(�popr�itemsr	�factoryr<�initialr
�callable�	mandatoryr3�formatr,rr&�AttributeError�joinrrr)r5�kwargsr8�factory_fieldsrA�missing_fieldsr9rr6r7rFr+s           �rr(zPClass.__new__.s�����v�s�+�C�0�����$5�t�<���z�z�.�$�7�������-�-�3�3�5�	L�K�D�%��v�~�!�)�T�^�-C�6�v�u�l�S� %�
�
�f�T�l��
� V�� %�
�
�f�T�l� ;��"�4�L�E�#�C���e�V�EU�V��4�L����&7�7�-5�e�m�m�-D�%�-�-�/�%�-�-��#����g�v�7G�I�����%�%�i�&6�&6�s�|�|�T�&J�K�!	L�$�~�$�U�+;�%<�e�N�>S�Um�n�n�� �!S�!Z�!Z��	�	�&�!�3�<�<�"1�2�
2�	 ���(>�(>�?� $����
rc���|r|d||d<t|�}|jD]&}||vs�t||t�}|tus�"|||<�(|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)
        rrr@r )�setr�getattr�_MISSING_VALUEr+)�self�argsrLrMr"r7s      rrPz
PClass.setRsx��&�"�1�g�F�4��7�O��V����&�&�	(�C��&� ���c�>�:����.�"'�F�3�K�		(��t�~�~�G�n�G��G�Grc��t||�r|S|r"|jD�cic]
}||vs�|||��}}|d||d�|��Scc}w)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.
        )r@rAr )�
isinstancer)r5rLr@rA�ks     r�createz
PClass.creatersY���f�c�"��M��,/�,>�,>�N�q�!�v�+�a����l�N�F�N��X�?��X�QW�X�X��Os�	>�>c��i}|jD]C}t||t�}|tus�t|j|j||�||<�E|S)z�
        Serialize the current PClass using custom serializer functions for fields where
        such have been supplied.
        )rrQrRr�
serializer)rSrIr8rr7s     rrzPClass.serialize�sa��
���'�'�	^�D��D�$��7�E��N�*�(��)<�)<�T�)B�)M�)M�v�W\�]��t��	^�
�
rc��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
)rS�transformationss  rrzPClass.transform�s�����/�/rc��t||j�r7|jD]'}t||t�t||t�k7s�'yyt
S)NFT)rVr+rrQrR�NotImplemented)rS�otherrs   r�__eq__z
PClass.__eq__�sM���e�T�^�^�,��+�+�
!���4��~�6�'�%��~�:^�^� �
!���rc��||k(Srr )rSr_s  r�__ne__z
PClass.__ne__�s���5�=� � rc�R��tt�fd��jD���S)Nc3�D�K�|]}|t�|t�f���y�wr)rQrR�r!r"rSs  �rr#z"PClass.__hash__.<locals>.<genexpr>�s�����c��3���c�>� B�C�c�s� )�hashr&r�rSs`r�__hash__zPClass.__hash__�s����E�c�t�Ob�Ob�c�c�d�drc�~��t|dd�rtdj||���tt|�||�y)NrFz'Can't set attribute, key={0}, value={1})rQrJrIr'r>�__setattr__�rSr"r7r+s   �rrjzPClass.__setattr__�s<����4�)�5�1� �!J�!Q�!Q�RU�W\�!]�^�^�
�f�d�'��U�3rc�6�tdj|���)Nz-Can't delete attribute, key={0}, use remove())rJrI)rSr"s  r�__delattr__zPClass.__delattr__�s�� �!P�!W�!W�X[�!\�]�]rc�j�i}|jD]!}t||t�}|tus�|||<�#|Sr)rrQrR)rSr8r"r7s    r�_to_dictzPClass._to_dict�sB�����&�&�	$�C��D�#�~�6�E��N�*�#��s��	$�
�
rc��dj|jjdjd�|j	�j�D���S)Nz{0}({1})rBc3�XK�|]"\}}dj|t|�����$y�w)z{0}={1}N)rI�repr)r!rW�vs   rr#z"PClass.__repr__.<locals>.<genexpr>�s%����*l�D�A�q�9�+;�+;�A�t�A�w�+G�*l�s�(*)rIr+r,rKrorDrgs r�__repr__zPClass.__repr__�sH��� � ����!8�!8�!%���*l�TX�Ta�Ta�Tc�Ti�Ti�Tk�*l�!l�n�	nrc�h��t�fd��jD��}t�j|ffS)Nc3�T�K�|]}t�|�s�|t�|�f���!y�wr)�hasattrrQres  �rr#z$PClass.__reduce__.<locals>.<genexpr>�s)�����c�#�PW�X\�^a�Pb�S�'�$��,�-�c�s�(�()�dictrrr+)rS�datas` r�
__reduce__zPClass.__reduce__�s-����c��9L�9L�c�c������� 7�7�7rc�6�t||j��S)z5
        Returns an evolver for this object.
        )�_PClassEvolverrorgs r�evolverzPClass.evolver�s���d�D�M�M�O�4�4rc�H�|j�}||=|j�S)z�
        Remove attribute given by name from the current instance. Raises AttributeError if the
        attribute doesn't exist.
        )r}�
persistent)rSrr}s   r�removez
PClass.remove�s%��
�,�,�.���D�M��!�!�#�#r�NFr)r,r-r.�__doc__r(rP�classmethodrXrrr`rbrhrjrmrortrzr}r�r/r0s@rr>r>%sj����"�HH�@�Y��Y� �0��!�e�4�^��n�8�
5�$rr>)�	metaclassc�R��eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
�fd	�Zd
�Z�xZ
S)r|)�_pclass_evolver_original�_pclass_evolver_data�_pclass_evolver_data_is_dirtyr@c�L�||_||_d|_t�|_yr�)r�r�r�rPr@)rS�original�initial_dicts   r�__init__z_PClassEvolver.__init__�s$��(0��%�$0��!�-2��*�"�u��rc� �|j|Sr)r��rS�items  r�__getitem__z_PClassEvolver.__getitem__�s���(�(��.�.rc��|jj|t�|ur1||j|<|jj	|�d|_|S�NT)r��getrRr@�addr��rSr"r7s   rrPz_PClassEvolver.set�sN���$�$�(�(��n�=�U�J�-2�D�%�%�c�*�� � �$�$�S�)�15�D�.��rc�(�|j||�yr)rPr�s   r�__setitem__z_PClassEvolver.__setitem__�s������e�rc��||jvr1|j|=|jj|�d|_|St	|��r�)r�r@�discardr�rJr�s  rr�z_PClassEvolver.remove�sJ���4�,�,�,��)�)�$�/�� � �(�(��.�15�D�.��K��T�"�"rc�&�|j|�yr)r�r�s  r�__delitem__z_PClassEvolver.__delitem__�s�����D�rc��|jr2|jjdd|ji|j��S|jS)Nr@r )r�r�r+r@r�rgs rrz_PClassEvolver.persistent�sS���-�-�:�4�0�0�:�:�X�4�K_�K_�X�=A�=V�=V�X�
X��,�,�,rc�p��||jvr|j||�ytt|�||�yr)r$rPr'r|rjrks   �rrjz_PClassEvolver.__setattr__�s.����d�n�n�$��H�H�S�%� ��.�$�3�C��?rc��||Srr r�s  r�__getattr__z_PClassEvolver.__getattr__s���D�z�r)r,r-r.r$r�r�rPr�r�r�rrjr�r/r0s@rr|r|�s6���x�I�%�/���#��-�@�rr|N)�pyrsistent._checked_typesrrrr�pyrsistent._field_commonrrr	r
rr�pyrsistent._transformationsrr�typer�objectrRr<r>r|r rr�<module>r�sX��j�j���2�7�E��E����%�m$�[�J�m$�`1�V�1r

Zerion Mini Shell 1.0