a
    yn„f¢  ã                   @  s6  U d Z ddlmZ ddlZddlZddlZddlmZ ddlm	Z	 ddl
mZmZmZmZmZ ejdk rrddlZnddlmZ eržddlmZ dd	lmZmZ eG d
d„ deƒƒZe ¡ Zdaded< dadd„ Zddœdd„Z da!e	dd„ ƒZ"dddœdd„Z#ddddddd œd!d"„Z$ddddddd#d$œd%d&„Z%dS )'zEInterface for plugin-configurable pickle __reduce_ex__ implementationé    )ÚannotationsN)ÚMapping)Úcontextmanager)ÚTYPE_CHECKINGÚAnyÚJSONMappingÚProtocolÚruntime_checkable)é   é   )Ú	ShapeItem)ÚArrayÚRecordc                   @  s   e Zd Zddddœdd„ZdS )ÚPickleReducerr   Úintútuple | NotImplemented)ÚobjÚprotocolÚreturnc                 C  s   d S ©N© )Úselfr   r   r   r   úR/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/awkward/_pickle.pyÚ__call__   ó    zPickleReducer.__call__N)Ú__name__Ú
__module__Ú__qualname__r   r   r   r   r   r      s   r   zPickleReducer | NoneÚ_pluginFc               	   C  st   d } t jdd�D ]^}| ¡ }zt|tƒs,J ‚W n* tyX   tjd|› �dd� Y qY n0 | d urjtdƒ‚|} q| S )Nzawkward.pickle.reduce)Úgroupz.Couldn't load `awkward.pickle.reduce` plugin: é   )Ú
stacklevelzYEncountered multiple Awkward pickle reducers under the `awkward.pickle.reduce` entrypoint)	Úimportlib_metadataÚentry_pointsÚloadÚ
isinstancer   ÚAssertionErrorÚwarningsÚwarnÚRuntimeError)Zbest_pluginÚentry_pointÚpluginr   r   r   Ú_load_reduce_plugin$   s"    þ
ÿr,   )r   c                   C  s`   t �H tstƒ adatdu r,W d  ƒ dS tW  d  ƒ S W d  ƒ n1 sR0    Y  dS )zƒ
    Returns the implementation of a custom __reduce_ex__ function for Awkward
    highlevel objects, or None if none provided
    TN)Ú_register_lockÚ_is_registeredr,   r   r   r   r   r   Úget_custom_reducer<   s    r/   c                  c  s$   t d } a zd V  W | a n| a 0 d S )NT)Ú_DISABLE_CUSTOM_REDUCER)Ú	old_valuer   r   r   Úuse_builtin_reducerQ   s    
r2   r   r   )r   r   c                 C  s$   t ƒ  }d u strtS || |ƒS d S r   )r/   r0   ÚNotImplemented)r   r   r+   r   r   r   Úcustom_reduce[   s    r4   Údictr   zMapping[str, Any]zJSONMapping | Noner   )Ú	form_dictÚlengthÚ	containerÚbehaviorÚattrsr   c                 C  s(   ddl m} || ||d||ddddd�
S )	Nr   ©Ú_implÚcpuTú{form_key}-{attribute}ú<F©Úbackendr9   r:   Z	highlevelZ
buffer_keyÚ	byteorderÚsimplify)Ú"awkward.operations.ak_from_buffersr<   )r6   r7   r8   r9   r:   r<   r   r   r   Úunpickle_array_schema_1b   s    örE   r   )r6   r7   r8   r9   r:   Úatr   c                 C  sX   ddl m} ddlm} ddlm} || ||d||ddddd�
}	||	|ƒ}
||
||d	�S )
Nr   )r   r;   r=   Fr>   r?   r@   )r9   r:   )Úawkward.highlevelr   rD   r<   Zawkward.record)r6   r7   r8   r9   r:   rF   r   r<   ZLowLevelRecordZarray_layoutZlayoutr   r   r   Úunpickle_record_schema_1y   s"    ö
rH   )&Ú__doc__Ú
__future__r   ÚsysÚ	threadingr'   Úcollections.abcr   Ú
contextlibr   Zawkward._typingr   r   r   r   r	   Úversion_infor"   Úimportlib.metadataÚmetadataZawkward._nplikes.shaper   rG   r   r   r   ÚLockr-   r   Ú__annotations__r.   r,   r/   r0   r2   r4   rE   rH   r   r   r   r   Ú<module>   s4   


	