Current Dir: /snap/core22/2955/usr/lib/python3/dist-packages/pyrsistent/__pycache__/

[FILE] typing.cpython-310.pyc [ edit | delete | rename ]
[FILE] _checked_types.cpython-310.pyc [ edit | delete | rename ]
[FILE] _field_common.cpython-310.pyc [ edit | delete | rename ]
[FILE] _helpers.cpython-310.pyc [ edit | delete | rename ]
[FILE] _immutable.cpython-310.pyc [ edit | delete | rename ]
[FILE] _pbag.cpython-310.pyc [ edit | delete | rename ]
[FILE] _pclass.cpython-310.pyc [ edit | delete | rename ]
[FILE] _pdeque.cpython-310.pyc [ edit | delete | rename ]
[FILE] _plist.cpython-310.pyc [ edit | delete | rename ]
[FILE] _pmap.cpython-310.pyc [ edit | delete | rename ]
[FILE] _precord.cpython-310.pyc [ edit | delete | rename ]
[FILE] _pset.cpython-310.pyc [ edit | delete | rename ]
[FILE] _pvector.cpython-310.pyc [ edit | delete | rename ]
[FILE] _toolz.cpython-310.pyc [ edit | delete | rename ]
[FILE] _transformations.cpython-310.pyc [ edit | delete | rename ]
[FILE] __init__.cpython-310.pyc [ edit | delete | rename ]

Viewing: /snap/core22/2955/usr/lib/python3/dist-packages/pyrsistent/__pycache__/_precord.cpython-310.pyc

o

���ax�@s�ddlmZmZmZmZddlmZmZmZm	Z	m
Z
mZddlm
Z
mZGdd�de�ZGdd�de
eed�ZGd	d
�d
e
j�ZdS)�)�CheckedType�_restore_pickle�InvariantException�store_invariants)�
set_fields�
check_type�is_field_ignore_extra_complaint�PFIELD_NO_INITIAL�	serialize�check_global_invariants)�PMap�pmapcseZdZ�fdd�Z�ZS)�_PRecordMetacsvt||dd�t||dd�tdd�|d��D��|d<tdd�|d��D��|d	<d
|d<tt|��||||�S)N�_precord_fields)�name�_precord_invariants�
__invariant__css�|]
\}}|jr|VqdS�N)�	mandatory)�.0r�field�r�5/usr/lib/python3/dist-packages/pyrsistent/_precord.py�	<genexpr>��z'_PRecordMeta.__new__.<locals>.<genexpr>�_precord_mandatory_fieldscss(�|]\}}|jtur||jfVqdSr)�initialr	)r�krrrrrs�&�_precord_initial_valuesr�	__slots__)rr�set�items�dict�superr�__new__)�mcsr�bases�dct��	__class__rrr$	s��z_PRecordMeta.__new__)�__name__�
__module__�__qualname__r$�
__classcell__rrr(rrsrcs\eZdZdZ�fdd�Z�fdd�Zdd�Zdd	�Zeddd
��Z	dd�Z
ddd�Z�ZS)�PRecordau
    A PRecord is a PMap with a fixed set of specified fields. Records are declared as python classes inheriting
    from PRecord. Because it is a PMap it has full support for all Mapping methods such as iteration and element
    access using subscript notation.

    More documentation and examples of PRecord usage is available at https://github.com/tobgu/pyrsistent
    cs�d|vrd|vrtt|��||d|d�S|�dd�}|�dd�}|}|jr8tdd�|j��D��}|�|�t|t	t
|j�d�||d	�}|��D]\}}|||<qJ|��S)
N�
_precord_size�_precord_buckets�_factory_fields�
_ignore_extraFcss*�|]\}}|t|�r|�n|fVqdSr)�callable�rr�vrrrr-s��z"PRecord.__new__.<locals>.<genexpr>)�pre_size�r1r2)
r#r.r$�poprr"r!�update�_PRecordEvolverr
�lenr�
persistent)�cls�kwargs�factory_fields�ignore_extra�initial_values�err5r(rrr$!s�

zPRecord.__new__cs(|rtt|��|d|d�S|�|�S)a
        Set a field in the record. This set function differs slightly from that in the PMap
        class. First of all it accepts key-value pairs. Second it accepts multiple key-value
        pairs to perform one, atomic, update of multiple fields.
        r�)r#r.r r9)�self�argsr>r(rrr 7s	
zPRecord.setcCst|j|�S)z4
        Returns an evolver of this object.
        )r:r)�rDrrr�evolverEszPRecord.evolvercCs$d�|jjd�dd�|��D���S)Nz{0}({1})z, css$�|]
\}}d�|t|��VqdS)z{0}={1}N)�format�reprr4rrrrMs�"z#PRecord.__repr__.<locals>.<genexpr>)rHr)r*�joinr!rFrrr�__repr__Ks
�zPRecord.__repr__NFcs:t�|�r�S|r�fdd�|jD��|d||d����S)a<
        Factory method. Will create a new PRecord 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 PRecord.
        csi|]}|�vr|�|�qSrr)rr�r>rr�
<dictcomp>\sz"PRecord.create.<locals>.<dictcomp>r7Nr)�
isinstancer)r=r>r1r@rrLr�createOs

	zPRecord.createcCst|jt|�ffSr)rr)r"rFrrr�
__reduce__`szPRecord.__reduce__cst��fdd����D��S)z�
        Serialize the current PRecord using custom serializer functions for fields where
        such have been supplied.
        c3s,�|]\}}|t�j|j�|�fVqdSr)r
r�
serializerr4�rHrDrrris�*z$PRecord.serialize.<locals>.<genexpr>)r"r!)rDrHrrRrr
dszPRecord.serialize�NFr)
r*r+r,�__doc__r$r rGrK�classmethodrOrPr
r-rrr(rr.sr.)�	metaclasscsBeZdZdZd�fdd�	Zdd�Z�fdd	�Z�fd
d�Z�ZS)
r:)�_destination_cls�_invariant_error_codes�_missing_fieldsr1r2NFcs2tt|��|�||_g|_g|_||_||_dSr)r#r:�__init__rWrXrYr1r2)rDr=�
original_pmapr1r2r(rrrZos
z_PRecordEvolver.__init__cCs|�||�dSr)r )rD�key�original_valuerrr�__setitem__wsz_PRecordEvolver.__setitem__c
s�|jj�|�}|rq|jdus||jvrOztt||j�r$|j||jd�}n|�|�}Wn&tyN}z|j	|j
7_	|j|j7_|WYd}~Sd}~ww|}t
|j|||�|�|�\}}|sh|j	�|�tt|��||�Std�||jj���)N)r@z/'{0}' is not among the specified fields for {1})rWr�getr1rr.r2�factoryrrX�invariant_errorsrY�missing_fieldsr�	invariant�appendr#r:r �AttributeErrorrHr*)rDr\r]r�valuerB�is_ok�
error_coder(rrr zs*
���z_PRecordEvolver.setcs�|j�|��}tt|���}|st|��s�|j|jd�}n|}�jr:|j	t
�fdd��jt|���D��7_	|j
s@|j	rLtt
|j
�t
|j	�d��t|�j�|S)N)r0r/c3s�|]
}d��j|�VqdS)z{0}.{1}N)rHr*)r�f�r=rrr�rz-_PRecordEvolver.persistent.<locals>.<genexpr>zField invariant failed)rW�is_dirtyr#r:r<rN�_buckets�_sizerrY�tupler �keysrXrrr)rDrk�pm�resultr(rjrr<�s ��z_PRecordEvolver.persistentrS)	r*r+r,rrZr^r r<r-rrr(rr:lsr:N)�pyrsistent._checked_typesrrrr�pyrsistent._field_commonrrrr	r
r�pyrsistent._pmaprr
�typerr.�_Evolverr:rrrr�<module>s S
Upload File: