%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib64/python3.9/site-packages/pyrsistent/__pycache__/
Upload File :
Create Path :
Current File : //lib64/python3.9/site-packages/pyrsistent/__pycache__/_field_common.cpython-39.pyc

a

`�]_
-�@sdddlZddlmZmZmZmZmZmZmZm	Z	m
Z
ddlmZddlm
Z
ddlZejddkZdd�Zdd	�Zd
d�Zdd
�Zdd�Zdd�ZGdd�de�ZdZdd�Zdd�Ze�Zdd�Zeeedeefdd�Zdd�ZGdd�de �Z!ed ed!iZ"iZ#d"d#�Z$d$d%�Z%d&d'�Z&d(d)�Z'd5d*d+�Z(d6d,d-�Z)d.d�Z*iZ+d/d0�Z,d1d2�Z-defd3d4�Z.dS)7�N)	�CheckedPMap�CheckedPSet�CheckedPVector�CheckedType�InvariantException�_restore_pickle�get_type�maybe_parse_user_type�maybe_parse_many_user_types)�optional)�wrap_invariant�csVtt�fdd�|D�g��|�<t|���D]$\}}t|t�r,||�|<||=q,dS)Ncs"g|]}t|j��i�����qS�)�list�__dict__�get�items)�.0�b��namer�>/usr/lib64/python3.9/site-packages/pyrsistent/_field_common.py�
<listcomp>�zset_fields.<locals>.<listcomp>)�dict�sumrr�
isinstance�_PField)Zdct�basesr�k�vrrr�
set_fieldss
 
r!cs4tdd��fdd�|D�D��}|r0t|dd��dS)Ncss|]\}}|s|VqdS�Nr)rZis_okZ
error_coderrr�	<genexpr>s
�z*check_global_invariants.<locals>.<genexpr>c3s|]}|��VqdSr"r)r�	invariant��subjectrrr# rrzGlobal invariant failed)�tupler)r&Z
invariantsZerror_codesrr%r�check_global_invariantss
�r(cCs&t|t�r|tur|�|�S|||�Sr")rr�PFIELD_NO_SERIALIZER�	serialize)�
serializer�format�valuerrrr*%s
r*csN|jrJt�fdd�|jD��sJt��}d�|j||j�}t|||j||��dS)Nc3s|]}t�t|��VqdSr")rr�r�t�r-rrr#-rzcheck_type.<locals>.<genexpr>z'Invalid type for field {0}.{1}, was {2})�type�anyr,�__name__�
PTypeError)Zdestination_cls�fieldrr-�actual_type�messagerr0r�
check_type,sr8cCs:t|�turdSt|�}t|�dkr(dStt|d�|�S)NTrF)r1�setr'�len�
issubclassr)�type_clsZ
field_type�typesrrr�is_type_cls3sr>cCsD|sdSt||j�sdStr.dt�|j�jvSdt�|j�jvSdS)NF�ignore_extra)	r>r1�PY2�inspectZ
getargspec�factory�argsZ	signature�
parameters)r<r5r?rrr�is_field_ignore_extra_complaint<srEc@s$eZdZdZdd�Zedd��ZdS)r�r1r$�initial�	mandatory�_factoryr+cCs(||_||_||_||_||_||_dSr"rF)�selfr1r$rGrHrBr+rrr�__init__Nsz_PField.__init__cCs@|jtur:t|j�dkr:tt|j�d�}t|t�r:|jS|jS)N�r)	rI�PFIELD_NO_FACTORYr:r1rr'r;r�create)rJ�typrrrrBVs

z_PField.factoryN)r3�
__module__�__qualname__�	__slots__rK�propertyrBrrrrrKsrrcCsdS)N)TNr)�_rrr�<lambda>arrUcCs|Sr"r)�xrrrrUbrcCs|Sr"r)rTr-rrrrUdrFc	Csft|tttf�rtt|��}ntt|��}|tkrBt|�rBt|�n|}t	||||||d�}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
    )r1r$rGrHrBr+)rrr9r'r
r	�PFIELD_NO_INVARIANT�callablerr�_check_field_parameters)	r1r$rGrHrBr+r=Zinvariant_functionr5rrrr5gs�r5cs��jD]*}t|t�st|t�std�t|����q�jturxt�j�sx�jrxt�fdd��jD��sxtd�t�j����t�j	�s�td��t�j
�s�td��t�j�s�td��dS)Nz Type parameter expected, not {0}c3s|]}t�j|�VqdSr")rrGr.�r5rrr#�rz*_check_field_parameters.<locals>.<genexpr>zInitial has invalid type {0}zInvariant must be callablezFactory must be callablezSerializer must be callable)r1r�str�	TypeErrorr,rG�PFIELD_NO_INITIALrXr2r$rBr+)r5r/rrZrrY�s"

���


rYcs eZdZdZ�fdd�Z�ZS)r4a
    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
    cs2tt|�j|i|��||_||_||_||_dSr")�superr4rK�source_classr5�expected_typesr6)rJr_r5r`r6rC�kwargs��	__class__rrrK�s
zPTypeError.__init__)r3rPrQ�__doc__rK�
__classcell__rrrbrr4�s	r4ZPVectorZPSetcCst||f}t||�S)z=Unpickling function for auto-generated PVec/PSet field types.)�_seq_field_typesr)�
checked_class�	item_type�data�type_rrr�_restore_seq_field_pickle�srkcCsd�dd�|D��S)z4Convert a tuple of types to a human-readable string.�css|]}t|�j��VqdSr")rr3�
capitalize)rrOrrrr#�rz"_types_to_names.<locals>.<genexpr>)�join)r=rrr�_types_to_names�srocsXt���f�}|dur|SG��fdd�d��}t�}t|j�||_|t��f<|S)zFCreate a subclass of the given checked class with the given item type.NcseZdZ�Z��fdd�ZdS)z%_make_seq_field_type.<locals>.TheTypecst��t|�ffSr")rkr�rJ�rgrhrr�
__reduce__�s�z0_make_seq_field_type.<locals>.TheType.__reduce__N)r3rPrQZ__type__rrrrqrr�TheType�srs)rfr�SEQ_FIELD_TYPE_SUFFIXESroZ_checked_typesr3)rgrhrjrs�suffixrrqr�_make_seq_field_type�srvcsDt||��|rd�fdd�	}n�j}t|r2t��n�|d||�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.
    NFcs |durdS�j|||d�SdS)N)�_factory_fieldsr?�rN)�argumentrwr?�rsrrrB�sz _sequence_field.<locals>.factoryT)r1rBrHrG)NF)rvrNr5�
optional_type)rgrhrrGrBrrzr�_sequence_field�s
�r|cCstt|||�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�rhrrGrrr�
pset_field�s�r~cCstt|||�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|rr}rrr�
pvector_fields�rcCsdS)N)Trlr)�itemrrrrUrcCst||f}t||�S)z8Unpickling function for auto-generated PMap field types.)�_pmap_field_typesr)�key_type�
value_typerirjrrr�_restore_pmap_field_picklesr�csZt���f�}|dur|SG��fdd�dt�}d�t|j�t|j��|_|t��f<|S)zDCreate a subclass of CheckedPMap with the given key and value types.NcseZdZ�Z�Zdd�ZdS)z%_make_pmap_field_type.<locals>.TheMapcSst|j|jt|�ffSr")r��__key_type__�__value_type__rrprrrrr%s�z0_make_pmap_field_type.<locals>.TheMap.__reduce__N)r3rPrQr�r�rrr�r�r�rr�TheMap!sr�z{0}To{1}PMap)r�rrr,roZ_checked_key_typesZ_checked_value_typesr3)r�r�rjr�rr�r�_make_pmap_field_types�r�csBt||��|r�fdd�}n�j}td��|r6t��n�||d�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``.
    cs|durdS��|�SdSr"rx)ry�r�rrrB?szpmap_field.<locals>.factoryT)rHrGr1rBr$)r�rNr5r{)r�r�rr$rBrr�r�
pmap_field0s
�r�)Fr)Fr)/�sysZpyrsistent._checked_typesrrrrrrrr	r
rr{rrA�version_infor@r!r(r*r8r>rE�objectrZPFIELD_NO_TYPErWrMr]r)r5rYr\r4rtrfrkrorvr|r~rZ_validr�r�r�r�rrrr�<module>sJ,		�
$�



Zerion Mini Shell 1.0