a
    zn„f†  ã                   @  sZ   d Z ddlmZ ddlZddlmZ ddlZe d¡ZG dd„ dej	j
eƒZeejd< dS )	z8
This module defines a versionless model for ``TList``.
é    )ÚannotationsN)ÚSequencez>ic                   @  sX   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zed
d„ ƒZ	dd„ Z
dZdd„ Zdd„ ZdS )ÚModel_TListz@
    A versionless :doc:`uproot.model.Model` for ``TList``.
    c                 C  s  t j |¡d urt jj ¡ ‚| jr@tdt| ƒj	› d| j
j› �ƒ‚| j t jjjj||||| j| j| jd�¡ | ||¡| jd< | |t|¡| jd< g | _g | _g | _g | _t| jd ƒD ]Z}| j |j¡ t j  ||||| j| j¡}| j |¡ | j | !||¡¡ | j |j¡ q¸d S )Nzmemberwise serialization of z	
in file )ÚconcreteÚfNameÚfSize)"ÚuprootZ_awkwardforthZget_forth_objZinterpretationÚobjectsZCannotBeForthZis_memberwiseÚNotImplementedErrorÚtypeÚ__name__ÚfileÚ	file_pathÚ_basesÚappendÚmodelsZTObjectZModel_TObjectÚreadÚ_fileÚ_parentr   ÚstringÚ_membersÚfieldÚ_tlist_format1Ú_startsÚ_dataÚ_optionsÚ_stopsÚrangeÚindexZdeserializationZread_object_anyÚ
bytestring)ÚselfÚchunkÚcursorÚcontextr   Ú_Úitem© r&   úV/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/uproot/models/TList.pyÚread_members   sB    ÿÿ
ùÿÿzModel_TList.read_membersc                 C  sF   | j d u rd}nd| j › d�}d| j› |› dt| ƒ› dt| ƒd›d�S )	NÚ z
 (version ú)ú<z of z items at 0xZ012xú>)Zclass_versionÚ	classnameÚlenÚid)r    Úversionr&   r&   r'   Ú__repr__9   s    
zModel_TList.__repr__c                 C  s
   | j | S ©N)r   )r    Úwherer&   r&   r'   Ú__getitem__@   s    zModel_TList.__getitem__c                 C  s
   t | jƒS r2   )r.   r   ©r    r&   r&   r'   Ú__len__C   s    zModel_TList.__len__c                 C  s   t | j| jƒS r2   )Úzipr   r   r5   r&   r&   r'   Úbyte_rangesF   s    zModel_TList.byte_rangesc                 C  s&   dddd„ | j D ƒdgt| j ƒ dœS )NÚTListc                 S  s   g | ]}|  ¡ ‘qS r&   )Útojson©Ú.0Úxr&   r&   r'   Ú
<listcomp>N   ó    z&Model_TList.tojson.<locals>.<listcomp>r)   )Z	_typenameÚnameZarrÚopt)r   r.   r5   r&   r&   r'   r:   J   s
    üzModel_TList.tojsonTc                 C  s   |j | _ |j| _d S r2   )r   r   )r    Úoriginalr&   r&   r'   Ú_to_writable_postprocessT   s    z$Model_TList._to_writable_postprocessc                 C  s   | j d t| jƒ  kr&t| jƒks0n J dƒ‚dd l}t|ƒ}| jD ]}| |dd |¡ qF| |j 	| j d ¡¡ | t
 | j d ¡¡ t| j| jƒD ]*\}}	|j ||d ¡ | |j |	¡¡ q˜|rütdd„ ||d … D ƒƒ}
d}| ||j |
|¡¡ d S )	Nr   z#Fatal error in TList serialization.r   Tr   c                 s  s   | ]}t |ƒV  qd S r2   )r.   r;   r&   r&   r'   Ú	<genexpr>k   r?   z)Model_TList._serialize.<locals>.<genexpr>é   )r   r.   r   r   Zuproot.writing._cascader   Ú
_serializer   Zserializationr   r   Úpackr7   Z_serialize_object_anyr   ÚsumÚinsertZnumbytes_version)r    ÚoutÚheaderr@   Ztobject_flagsr   r3   r=   ZdatumÚoptionÚ	num_bytesr0   r&   r&   r'   rF   X   s&    ÿÿ
þ
zModel_TList._serializeN)r   Ú
__module__Ú__qualname__Ú__doc__r(   r1   r4   r6   Úpropertyr8   r:   ÚwritablerC   rF   r&   r&   r&   r'   r      s   $
r   r9   )rP   Ú
__future__r   ÚstructÚcollections.abcr   r   ÚStructr   ÚmodelZModelr   Úclassesr&   r&   r&   r'   Ú<module>   s   
`