<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet"
        integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.3.0/css/all.min.css"
        integrity="sha512-SzlrxWUlpfuzQ+pcUCosxcglQRNAq/DZjVsC0lE40xsADsfeQoEypE+enwcOiGjk/bSuGGKHEyjSoQ1zVisanQ=="
        crossorigin="anonymous" referrerpolicy="no-referrer" />
</head>
</html>
B
    [                 @   s   d dl Z d dlmZmZmZmZ d dlmZmZm	Z	m
Z
mZ d dlmZmZ G dd deZe eG dd deeZG d	d
 d
ejZdS )    N)CheckedType_restore_pickleInvariantExceptionstore_invariants)
set_fields
check_typePFIELD_NO_INITIAL	serializecheck_global_invariants)PMappmapc                   s   e Zd Z fddZ  ZS )_PRecordMetac                sv   t ||dd t||dd tdd |d  D |d< tdd |d  D |d	< d
|d< tt| | |||S )N_precord_fields)name_precord_invariantsZ__invariant__c             s   s   | ]\}}|j r|V  qd S )N)	mandatory).0r   field r   F/opt/alt/python37/lib64/python3.7/site-packages/pyrsistent/_precord.py	<genexpr>   s    z'_PRecordMeta.__new__.<locals>.<genexpr>_precord_mandatory_fieldsc             s   s&   | ]\}}|j tk	r||j fV  qd S )N)initialr   )r   kr   r   r   r   r      s    _precord_initial_valuesr   	__slots__)r   r   setitemsdictsuperr   __new__)Zmcsr   basesdct)	__class__r   r   r    	   s    z_PRecordMeta.__new__)__name__
__module____qualname__r    __classcell__r   r   )r#   r   r      s   r   c                   s\   e Zd ZdZ fddZ fddZdd Zdd	 ZedddZ	dd Z
ddd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
    c                s   d|kr,d|kr,t t| | |d |d S |dd }|}| jrdtdd | j D }|| t| t	 |d}x| D ]\}}|||< q~W |
 S )N_precord_size_precord_buckets_factory_fieldsc             s   s(   | ] \}}|t |r| n|fV  qd S )N)callable)r   r   vr   r   r   r   -   s   z"PRecord.__new__.<locals>.<genexpr>)r+   )r   r(   r    popr   r   r   update_PRecordEvolverr   
persistent)clskwargsZfactory_fieldsZinitial_valueser   r-   )r#   r   r   r    "   s    
zPRecord.__new__c                s(   |rt t| |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   r/   )selfargsr3   )r#   r   r   r   7   s    	zPRecord.setc             C   s   t | j| S )z4
        Returns an evolver of this object.
        )r0   r#   )r6   r   r   r   evolverE   s    zPRecord.evolverc             C   s$   d | jjddd |  D S )Nz{0}({1})z, c             s   s"   | ]\}}d  |t|V  qdS )z{0}={1}N)formatrepr)r   r   r-   r   r   r   r   M   s    z#PRecord.__repr__.<locals>.<genexpr>)r9   r#   r$   joinr   )r6   r   r   r   __repr__K   s    
zPRecord.__repr__NFc                s8   t  | r S |r& fdd| jD  | f d|i 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.
        c                s   i | ]}| kr | |qS r   r   )r   r   )r3   r   r   
<dictcomp>\   s    z"PRecord.create.<locals>.<dictcomp>r+   )
isinstancer   )r2   r3   r+   Zignore_extrar   )r3   r   createO   s
    	
zPRecord.createc             C   s   t | jt| ffS )N)r   r#   r   )r6   r   r   r   
__reduce__`   s    zPRecord.__reduce__c                s   t  fdd D S )z
        Serialize the current PRecord using custom serializer functions for fields where
        such have been supplied.
        c             3   s*   | ]"\}}|t j| j |fV  qd S )N)r	   r   Z
serializer)r   r   r-   )r9   r6   r   r   r   i   s    z$PRecord.serialize.<locals>.<genexpr>)r   r   )r6   r9   r   )r9   r6   r   r	   d   s    zPRecord.serialize)NF)N)r$   r%   r&   __doc__r    r   r8   r<   classmethodr?   r@   r	   r'   r   r   )r#   r   r(      s   r(   c                   sB   e Zd ZdZd fdd	Zdd Z fddZ fd	d
Z  ZS )r0   )_destination_cls_invariant_error_codes_missing_fieldsr+   Nc                s,   t t| | || _g | _g | _|| _d S )N)r   r0   __init__rC   rD   rE   r+   )r6   r2   Zoriginal_pmapr+   )r#   r   r   rF   o   s
    z_PRecordEvolver.__init__c             C   s   |  || d S )N)r   )r6   keyoriginal_valuer   r   r   __setitem__v   s    z_PRecordEvolver.__setitem__c          
      s   | j j|}|r| jd ks&|| jkrzy||}W q~ tk
rv } z$|  j|j7  _|  j|j	7  _| S d }~X Y q~X n|}t
| j ||| ||\}}|s| j| tt| ||S td|| j jd S )Nz/'{0}' is not among the specified fields for {1})rC   r   getr+   factoryr   rD   Zinvariant_errorsrE   Zmissing_fieldsr   Z	invariantappendr   r0   r   AttributeErrorr9   r$   )r6   rG   rH   r   valuer4   Zis_okZ
error_code)r#   r   r   r   y   s     z_PRecordEvolver.setc                s   | j  |  }tt|  }|s*t| s< |j|jd}n|} jrt|  j	t
 fdd jt|  D 7  _	| js| j	rtt
| jt
| j	dt| j |S )N)r*   r)   c             3   s   | ]}d   j|V  qdS )z{0}.{1}N)r9   r$   )r   f)r2   r   r   r      s    z-_PRecordEvolver.persistent.<locals>.<genexpr>zField invariant failed)rC   is_dirtyr   r0   r1   r>   Z_buckets_sizer   rE   tupler   keysrD   r   r
   r   )r6   rP   Zpmresult)r#   )r2   r   r1      s    z_PRecordEvolver.persistent)N)	r$   r%   r&   r   rF   rI   r   r1   r'   r   r   )r#   r   r0   l   s
   r0   )sixZpyrsistent._checked_typesr   r   r   r   Zpyrsistent._field_commonr   r   r   r	   r
   Zpyrsistent._pmapr   r   typer   Zadd_metaclassr(   Z_Evolverr0   r   r   r   r   <module>   s   
R