%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__/_field_common.cpython-312.pyc

�

n�9e�.��N�ddlmZmZmZmZmZmZmZmZm	Z	ddlm
ZddlmZddl
Z
d�Zd�Zd�Zd�Zd	�Zd
�ZGd�de�Zd
Zd�Zd�Ze�Zd�Zeeedeefd�Zd�ZGd�de�ZedediZiZ d�Z!d�Z"d�Z#eefd�Z$dd
eefd�Z%dd
eefd�Z&d�Z'iZ(d�Z)d �Z*defd!�Z+y)"�)	�CheckedPMap�CheckedPSet�CheckedPVector�CheckedType�InvariantException�_restore_pickle�get_type�maybe_parse_user_type�maybe_parse_many_user_types)�optional)�wrap_invariantNc
�6�tt|D�cgc]5}t|jj	|i�j����7c}g��||<t|j��D]!\}}t
|t�s�||||<||=�#ycc}w�N)�dict�sum�list�__dict__�get�items�
isinstance�_PField)�dct�bases�name�b�k�vs      �:/usr/lib/python3/dist-packages/pyrsistent/_field_common.py�
set_fieldsrs����S�%�P�Q�$�q�z�z�~�~�d�B�7�=�=�?�@�P�RT�U�V�C��I��S�Y�Y�[�!����1��a��!��C��I�a�L��A����Qs�:Bc�Z��td��fd�|D�D��}|r
t|dd��y)Nc3�*K�|]\}}|s|���
y�wr�)�.0�is_ok�
error_codes   r�	<genexpr>z*check_global_invariants.<locals>.<genexpr>s!����W�'8�u�j�PU�#�W�s�c3�.�K�|]}|�����y�wrr")r#�	invariant�subjects  �rr&z*check_global_invariants.<locals>.<genexpr>s�����H�	��7�+�H�s�r"zGlobal invariant failed)�tupler)r)�
invariants�error_codess`  r�check_global_invariantsr-s:����W�H�Z�H�W�W�K�� ��b�2K�L�L��c�f�t|t�r|tur|j|�S|||�Sr)rr�PFIELD_NO_SERIALIZER�	serialize)�
serializer�format�values   rr1r1!s0���%��%�*�8L�*L����v�&�&��f�e�$�$r.c����|jrjt�fd�|jD��sKt��}dj|j||j�}t	|||j||��yy)Nc3�H�K�|]}t�t|�����y�wr)rr	)r#�tr4s  �rr&zcheck_type.<locals>.<genexpr>)s�����Q��j�����<�Q�s�"z'Invalid type for field {0}.{1}, was {2})�type�anyr3�__name__�
PTypeError)�destination_cls�fieldrr4�actual_type�messages   `  r�
check_typer@(se����z�z�#�Q�e�j�j�Q�Q��5�k��;�B�B�?�C[�C[�]a�cn�cw�cw�x����$��
�
�K��Q�Q�R�zr.c��t|�turyt|�}t|�dk(ryt	t|d�|�S)NTrF)r8�setr*�len�
issubclassr	)�type_cls�
field_type�typess   r�is_type_clsrH/s@���J��3����*��E�
�5�z�Q����h�u�Q�x�(�(�3�3r.c��|syt||j�sydtj|j�j
vS)NF�ignore_extra)rHr8�inspect�	signature�factory�
parameters)rEr=rJs   r�is_field_ignore_extra_complaintrO8s9�����x����,���W�.�.�u�}�}�=�H�H�H�Hr.c�&�eZdZdZd�Zed��Zy)r�r8r(�initial�	mandatory�_factoryr2c�X�||_||_||_||_||_||_yrrQ)�selfr8r(rRrSrMr2s       r�__init__z_PField.__init__Gs,����	�"������"�����
�$��r.c���|jturUt|j�dk(r=t	t|j�d�}t
|t�r|jS|jS)N�r)	rT�PFIELD_NO_FACTORYrCr8r	r*rDr�create)rV�typs  rrMz_PField.factoryOsV���=�=�-�-�#�d�i�i�.�A�2E��5����+�A�.�/�C��#�{�+��z�z�!��}�}�r.N)r:�
__module__�__qualname__�	__slots__rW�propertyrMr"r.rrrDs ��W�I�%����r.rr"c��y)N)TNr")�_s r�<lambda>rcZ��r.c��|Srr")�xs rrcrc[s��a�r.c��|Srr")rbr4s  rrcrc]s���r.Fc��t|tttf�rtt	|��}ntt|��}|tk7rt|�rt|�n|}t||||||��}t|�|S)a
    Field specification factory for :py:class:`PRecord`.

    :param type: a type or iterable with types that are allowed for this field
    :param invariant: a function specifying an invariant that must hold for the field
    :param initial: value of field if not specified when instantiating the record
    :param mandatory: boolean specifying if the field is mandatory or not
    :param factory: function called when field is set.
    :param serializer: function that returns a serialized version of the field
    )r8r(rRrSrMr2)rrrBr*rr
�PFIELD_NO_INVARIANT�callabler
r�_check_field_parameters)	r8r(rRrSrMr2rG�invariant_functionr=s	         rr=r=`s|��,�$��s�E�*�+��/��5�6���)�$�/�0��6?�CV�6V�[c�dm�[n��	�2�t}����*<�g�'��Z�
Q�E��E�"��Lr.c�l���jD]F}t|t�r�t|t�r�%tdj	t|�����j
turlt�j
�sW�jrKt�fd��jD��s-tdj	t�j
����t�j�std��t�j�std��t�j�std��y)Nz Type parameter expected, not {0}c3�J�K�|]}t�j|����y�wr)rrR)r#r7r=s  �rr&z*_check_field_parameters.<locals>.<genexpr>�s�����"T�A�:�e�m�m�Q�#?�"T�s� #zInitial has invalid type {0}zInvariant must be callablezFactory must be callablezSerializer must be callable)r8r�str�	TypeErrorr3rR�PFIELD_NO_INITIALrjr9r(rMr2)r=r7s` rrkrk�s����
�Z�Z�P���!�T�"�:�a��+=��>�E�E�d�1�g�N�O�O�P�
�}�}�-�-�����'��J�J�s�"T����"T�T��6�=�=�d�5�=�=�>Q�R�S�S��E�O�O�$��4�5�5��E�M�M�"��2�3�3��E�$�$�%��5�6�6�&r.c�"��eZdZdZ�fd�Z�xZS)r;a
    Raised when trying to assign a value with a type that doesn't match the declared type.

    Attributes:
    source_class -- The class of the record
    field -- Field name
    expected_types  -- Types allowed for the field
    actual_type -- The non matching type
    c�d��tt|�
|i|��||_||_||_||_yr)�superr;rW�source_classr=�expected_typesr>)rVrur=rvr>�args�kwargs�	__class__s       �rrWzPTypeError.__init__�s6���
�j�$�(�$�9�&�9�(�����
�,���&��r.)r:r]r^�__doc__rW�
__classcell__)rys@rr;r;�s����'�'r.r;�PVector�PSetc�0�t||f}t||�S)z=Unpickling function for auto-generated PVec/PSet field types.)�_seq_field_typesr)�
checked_class�	item_type�data�type_s    r�_restore_seq_field_pickler��s���]�I�5�6�E��5�$�'�'r.c�2�djd�|D��S)z4Convert a tuple of types to a human-readable string.�c3�bK�|]'}t|�jj����)y�wr)r	r:�
capitalize)r#r\s  rr&z"_types_to_names.<locals>.<genexpr>�s#����H�3�8�C�=�)�)�4�4�6�H�s�-/)�join)rGs r�_types_to_namesr��s��
�7�7�H�%�H�H�Hr.c������tj��f�}|�|SG���fd�d��}t�}t|j�|z|_|t��f<|S)zFCreate a subclass of the given checked class with the given item type.c�&��eZdZW�ZW�Z��fd�Zy)�%_make_seq_field_type.<locals>.TheTypec�,��t��t|�ffSr)r�r)rVr�r�s ��r�
__reduce__z0_make_seq_field_type.<locals>.TheType.__reduce__�s���-�"�I�t�D�z�:�<�
<r.N)r:r]r^�__type__�
__invariant__r�)r��item_invariantr�s���r�TheTyper��s�����&�
�	<r.r�)rr�SEQ_FIELD_TYPE_SUFFIXESr��_checked_typesr:)r�r�r�r�r��suffixs```   r�_make_seq_field_typer��sm���� � �-��!;�<�E�����<�<�-�<�%�]�
3�F�&�w�'=�'=�>��G�G��18��]�I�-�.��Nr.c	���t|||��|rd�fd�	}n�j}t|rt��n�|d|||���S)a�
    Create checked field for either ``PSet`` or ``PVector``.

    :param checked_class: ``CheckedPSet`` or ``CheckedPVector``.
    :param item_type: The required type for the items in the set.
    :param optional: If true, ``None`` can be used as a value for
        this field.
    :param initial: Initial value to pass to factory.

    :return: A ``field`` containing a checked class.
    c�2��|�y�j|||��S)N)�_factory_fieldsrJ�r[)�argumentr�rJr�s   �rrMz _sequence_field.<locals>.factory�s"�������~�~�h��^j�~�k�kr.T)r8rMrSr(rR)NF)r�r[r=�
optional_type)r�r�rrRr(r�rMr�s       @r�_sequence_fieldr��sO���#�=�)�^�L�G��	l��.�.����m�G�,�g� �D�$� ��)�+�+r.c�,�tt|||||��S)al
    Create checked ``PSet`` field.

    :param item_type: The required type for the items in the set.
    :param optional: If true, ``None`` can be used as a value for
        this field.
    :param initial: Initial value to pass to factory if no value is given
        for the field.

    :return: A ``field`` containing a ``CheckedPSet`` of the given type.
    �r(r�)r�r�r�rrRr(r�s     r�
pset_fieldr��s���;�	�8�W�%.�*8�:�:r.c�,�tt|||||��S)au
    Create checked ``PVector`` field.

    :param item_type: The required type for the items in the vector.
    :param optional: If true, ``None`` can be used as a value for
        this field.
    :param initial: Initial value to pass to factory if no value is given
        for the field.

    :return: A ``field`` containing a ``CheckedPVector`` of the given type.
    r�)r�rr�s     r�
pvector_fieldr�s���>�9�h��%.�*8�:�:r.c��y)N)Tr�r")�items rrcrcrdr.c�0�t||f}t||�S)z8Unpickling function for auto-generated PMap field types.)�_pmap_field_typesr)�key_type�
value_typer�r�s    r�_restore_pmap_field_pickler�s���h�
�2�3�E��5�$�'�'r.c�����tj��f�}|�|SG��fd�dt�}djt	|j
�t	|j��|_|t��f<|S)zDCreate a subclass of CheckedPMap with the given key and value types.c� ��eZdZW�ZW�Zd�Zy)�%_make_pmap_field_type.<locals>.TheMapc�R�t|j|jt|�ffSr)r��__key_type__�__value_type__r)rVs rr�z0_make_pmap_field_type.<locals>.TheMap.__reduce__(s+��.��&�&��(;�(;�T�$�Z�H�J�
Jr.N)r:r]r^r�r�r�)r�r�s��r�TheMapr�$s�����#��	Jr.r�z{0}To{1}PMap)r�rrr3r��_checked_key_types�_checked_value_typesr:)r�r�r�r�s``  r�_make_pmap_field_typer�sx����!�!�8�Z�"8�9�E�����J��J�%�+�+���1�1�2���3�3�4�6�F�O�/5��h�
�*�+��Mr.c���t||��|r�fd�}n�j}td��|rt��n�||��S)ad
    Create a checked ``PMap`` field.

    :param key: The required type for the keys of the map.
    :param value: The required type for the values of the map.
    :param optional: If true, ``None`` can be used as a value for
        this field.
    :param invariant: Pass-through to ``field``.

    :return: A ``field`` containing a ``CheckedPMap``.
    c�,��|�y�j|�Srr�)r�r�s �rrMzpmap_field.<locals>.factoryBs�������}�}�X�.�.r.T)rSrRr8rMr()r�r[r=r�)r�r�rr(rMr�s     @r�
pmap_fieldr�3sH���#�8�Z�
8�F��	/��-�-���4���/7�m�F�+�V� �I�7�7r.),�pyrsistent._checked_typesrrrrrrr	r
rrr�r
rKrr-r1r@rHrO�objectr�PFIELD_NO_TYPErirZrqr0r=rkrpr;r�rr�r�r�r�r�r��_validr�r�r�r�r"r.r�<module>r�s��
�
�
�@�4���M�%�R�4�I��f��*��,�����H��-���)<�FW��#4�AU�!�H7�('��'�&�I�������(�
I��(2�#6�+�>$)�"�,�1�:�&',�R�/�!4�:�&
!����(�
�*/4�?R�7r.

Zerion Mini Shell 1.0