HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //usr/lib/python3/dist-packages/pyrsistent/__pycache__/_field_common.cpython-38.pyc
U

���]�,�@slddlZddlZddlmZmZmZmZmZmZm	Z	m
Z
mZddlmZ
ddlmZddlZejddkZdd�Zdd	�Zd
d�Zdd
�Zdd�Zdd�ZGdd�de�ZdZdd�Zdd�Ze�Zdd�Zeeedeefdd�Zdd�Z Gdd�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/lib/python3/dist-packages/pyrsistent/_field_common.py�
<listcomp>szset_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"!srzGlobal invariant failed)�tupler)r%Z
invariantsZerror_codesrr$r�check_global_invariantss
�r'cCs&t|t�r|tkr|�|�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".szcheck_type.<locals>.<genexpr>z'Invalid type for field {0}.{1}, was {2})�type�anyr+�__name__�
PTypeError)Zdestination_cls�fieldrr,�actual_type�messagerr/r�
check_type-sr7cCs:t|�tkrdSt|�}t|�dkr(dStt|d�|�S)NTrF)r0�setr&�len�
issubclassr)�type_clsZ
field_type�typesrrr�is_type_cls4sr=cCsD|sdSt||j�sdStr.dt�|j�jkSdt�|j�jkSdS)NF�ignore_extra)	r=r0�PY2�inspectZ
getargspec�factory�argsZ	signatureZ
parameters)r;r4r>rrr�is_field_ignore_extra_complaint=srCc@s$eZdZdZdd�Zedd��ZdS)r�r0r#�initial�	mandatory�_factoryr*cCs(||_||_||_||_||_||_dSr!rD)�selfr0r#rErFrAr*rrr�__init__Osz_PField.__init__cCs@|jtkr:t|j�dkr:tt|j�d�}t|t�r:|jS|jS)N�r)	rG�PFIELD_NO_FACTORYr9r0rr&r:r�create)rH�typrrrrAWs

z_PField.factoryN)r2�
__module__�__qualname__�	__slots__rI�propertyrArrrrrLsrrcCsdS)N)TNr)�_rrr�<lambda>b�rScCs|Sr!r)�xrrrrScrTcCs|Sr!r)rRr,rrrrSerTFc	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
    )r0r#rErFrAr*)rrr8r&r
r	�PFIELD_NO_INVARIANT�callablerr�_check_field_parameters)	r0r#rErFrAr*r<Zinvariant_functionr4rrrr4hs�r4cs��jD],}t|t�st|tj�std�t|����q�jtk	rzt�j�sz�jrzt	�fdd��jD��sztd�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!)rrEr-�r4rrr"�sz*_check_field_parameters.<locals>.<genexpr>zInitial has invalid type {0}zInvariant must be callablezFactory must be callablezSerializer must be callable)
r0r�sixZstring_types�	TypeErrorr+rE�PFIELD_NO_INITIALrWr1r#rAr*)r4r.rrYrrX�s"

���


rXcs eZdZdZ�fdd�Z�ZS)r3a
    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
    cs.tt|�j||�||_||_||_||_dSr!)�superr3rI�source_classr4�expected_typesr5)rHr^r4r_r5rB�kwargs��	__class__rrrI�s
zPTypeError.__init__)r2rNrO�__doc__rI�
__classcell__rrrarr3�s	r3ZPVectorZPSetcCst||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rjcCsd�dd�|D��S)z4Convert a tuple of types to a human-readable string.�css|]}t|�j��VqdSr!)rr2�
capitalize)rrMrrrr"�sz"_types_to_names.<locals>.<genexpr>)�join)r<rrr�_types_to_names�srncsXt���f�}|dk	r|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!)rjr�rH�rfrgrr�
__reduce__�s�z0_make_seq_field_type.<locals>.TheType.__reduce__N)r2rNrOZ__type__rqrrprr�TheType�srr)rer�SEQ_FIELD_TYPE_SUFFIXESrnZ_checked_typesr2)rfrgrirr�suffixrrpr�_make_seq_field_type�srucsBt||��|r�fdd�}n�j}t|r0t��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.
    cs|dkrdS��|�SdSr!�rL�Zargument�rrrrrA�sz _sequence_field.<locals>.factoryT)r0rArFrE)rurLr4�
optional_type)rfrgrrErArrxr�_sequence_field�s
�rzcCstt|||�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.
    )rzr�rgrrErrr�
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.
    )rzrr{rrr�
pvector_fields�r}cCsdS)N)Trkr)�itemrrrrSrTcCst||f}t||�S)z8Unpickling function for auto-generated PMap field types.)�_pmap_field_typesr)�key_type�
value_typerhrirrr�_restore_pmap_field_picklesr�csZt���f�}|dk	r|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__rrorrrrq&s�z0_make_pmap_field_type.<locals>.TheMap.__reduce__N)r2rNrOr�r�rqr�r�r�rr�TheMap"sr�z{0}To{1}PMap)rrrr+rnZ_checked_key_typesZ_checked_value_typesr2)r�r�rir�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|dkrdS��|�SdSr!rvrw�r�rrrA@szpmap_field.<locals>.factoryT)rFrEr0rAr#)r�rLr4ry)r�r�rr#rArr�r�
pmap_field1s
�r�)Fr)Fr)0rZ�sysZpyrsistent._checked_typesrrrrrrrr	r
rryrr@�version_infor?r r'r)r7r=rC�objectrZPFIELD_NO_TYPErVrKr\r(r4rXr[r3rsrerjrnrurzr|r}Z_validrr�r�r�rrrr�<module>sT,		�
$�