a
    zn„f? ã                
   @  sf  d Z ddlmZ ddlZddlZddlZddlZddlmZm	Z	 ddl
m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	dddd
œddœdd„Zddddejdkdddddœ	e_G dd„ deƒZg d¢ZG dd„ dƒZG dd„ deƒZe d¡Ze d¡ZG d d!„ d!eƒZe d"¡Ze d#¡Z e d$¡Z!G d%d&„ d&eƒZ"e d'¡Z#e d(¡Z$G d)d*„ d*ƒZ%dS )+a>  
This module defines the entry-point for opening a file, :doc:`uproot.reading.open`,
and the classes that are too fundamental to be models:
:doc:`uproot.reading.ReadOnlyFile` (``TFile``),
:doc:`uproot.reading.ReadOnlyDirectory` (``TDirectory`` or ``TDirectoryFile``),
and :doc:`uproot.reading.ReadOnlyKey` (``TKey``).
é    )ÚannotationsN)ÚMappingÚMutableMapping)ÚPath)ÚIO)Ú	no_filteréd   ú100 MB©Úobject_cacheÚarray_cacheÚcustom_classesÚdecompression_executorÚinterpretation_executorz,str | Path | IO | dict[str | Path | IO, str])Úpathc          
      K  sº   t | tƒr&t| ƒdkr&|  ¡ \\}}n$t | tƒrBtj | ¡\}}n| }d}tj |¡}t |tƒs‚t	|dƒrtt	|dƒs‚t
d| ›�ƒ‚t|f|||||dœ|¤Ž}	|du r¬|	jS |	j| S dS )aà  
    Args:
        path (str or ``pathlib.Path``): The filesystem path or remote URL of
            the file to open. If a string, it may be followed by a colon (``:``)
            and an object path within the ROOT file, to return an object,
            rather than a file. Path objects are interpreted strictly as
            filesystem paths or URLs.
            Examples: ``"rel/file.root"``, ``"C:\abs\file.root"``,
            ``"http://where/what.root"``,
            ``"https://username:password@where/secure.root"``,
            ``"rel/file.root:tdirectory/ttree"``, ``Path("rel:/file.root")``,
            ``Path("/abs/path:stuff.root")``
        object_cache (None, MutableMapping, or int): Cache of objects drawn
            from ROOT directories (e.g. histograms, TTrees, other directories);
            if None, do not use a cache; if an int, create a new cache of this
            size.
        array_cache (None, MutableMapping, or memory size): Cache of arrays
            drawn from ``TTrees``; if None, do not use a cache; if a memory
            size, create a new cache of this size.
        custom_classes (None or MutableMapping): If None, classes come from
            uproot.classes; otherwise, a container of class definitions that
            is both used to fill with new classes and search for dependencies.
        decompression_executor (None or Executor with a ``submit`` method): The
            executor that is used to decompress ``TBaskets``; if None, a
            :doc:`uproot.source.futures.TrivialExecutor` is created.
            Executors attached to a file are ``shutdown`` when the file is closed.
        interpretation_executor (None or Executor with a ``submit`` method): The
            executor that is used to interpret uncompressed ``TBasket`` data as
            arrays; if None, a :doc:`uproot.source.futures.TrivialExecutor`
            is created.
            Executors attached to a file are ``shutdown`` when the file is closed.
        options: See below.

    Opens a ROOT file, possibly through a remote protocol.

    If an object path is given, the return type of this function can be anything
    that can be extracted from a ROOT file (subclass of
    :doc:`uproot.model.Model`).

    If an object path is not given, the return type is a
    :doc:`uproot.reading.ReadOnlyDirectory` *and not*
    :doc:`uproot.reading.ReadOnlyFile`. ROOT objects can be extracted from a
    :doc:`uproot.reading.ReadOnlyDirectory` but not a
    :doc:`uproot.reading.ReadOnlyFile`.

    Options (type; default):

    * handler (:doc:`uproot.source.chunk.Source` class; None)
    * timeout (float for HTTP, int for XRootD; 30)
    * max_num_elements (None or int; None)
    * num_workers (int; 1)
    * use_threads (bool; False on the emscripten platform (i.e. in a web browser), else True)
    * num_fallback_workers (int; 10)
    * begin_chunk_size (memory_size; 403, the smallest a ROOT file can be)
    * minimal_ttree_metadata (bool; True)

    Any object derived from a ROOT file is a context manager (works in Python's
    ``with`` statement) that closes the file when exiting the ``with`` block.
    Therefore, the :doc:`uproot.reading.open` function can and usually should
    be used in a ``with`` statement to clean up file handles and threads
    associated with open files:

    .. code-block:: python

        with uproot.open("/path/to/file.root:path/to/histogram") as h:
            h.to_hist().plot()

        # file is now closed, even if an exception was raised in the block

    Other file entry points:

    * :doc:`uproot.reading.open` (this function): opens one file to read any
      of its objects.
    * :doc:`uproot.behaviors.TBranch.iterate`: iterates through chunks of
      contiguous entries in ``TTrees``.
    * :doc:`uproot.behaviors.TBranch.concatenate`: returns a single concatenated
      array from ``TTrees``.
    * :doc:`uproot._dask.dask`: returns an unevaluated Dask array from ``TTrees``.

    For remote ROOT files served over HTTP(S), basic authentication is supported.
    In this case, the credentials may be provided part of the URL in, as in
    ``https://username:password@example.org/secure/protected.root.`` Note that
    for security reasons, it is recommended basic authentication only be used
    for HTTPS resources.
    é   NÚreadÚseekz…'path' must be a string, pathlib.Path, an object with 'read' and 'seek' methods, or a length-1 dict of {file_path: object_path}, not r
   )Ú
isinstanceÚdictÚlenÚitemsÚstrÚuprootÚ_utilZfile_object_path_splitZregularize_pathÚhasattrÚ
ValueErrorÚReadOnlyFileÚroot_directory)
r   r   r   r   r   r   ÚoptionsÚ	file_pathÚobject_pathÚfile© r#   úQ/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/uproot/reading.pyÚopen   s>    _

ÿÿþÿÿúù
r%   é   r   Z
emscriptené
   i“  TiU  )	ÚhandlerÚtimeoutZmax_num_elementsZnum_workersZuse_threadsZnum_fallback_workersÚbegin_chunk_sizeZminimal_ttree_metadataZhttp_max_header_bytesc                   @  s   e Zd Zdd„ ZdS )Ú_OpenDefaultsc                 C  s   t ‚d S ©N)ÚNotImplementedError©Úselfr#   r#   r$   Ú__init__¬   s    z_OpenDefaults.__init__N)Ú__name__Ú
__module__Ú__qualname__r0   r#   r#   r#   r$   r+   «   s   r+   )ZTROOTÚ
TDirectoryÚTDirectoryFilezRooWorkspace::WSDirZTTreeZTChainZTProofChainZ
THbookTreeZTNtupleZTNtupleDZTTreeSQLzROOT::Experimental::RNTuplec                   @  s   e Zd ZdZedd„ ƒZedd„ ƒZedd„ ƒZedd	„ ƒZed
d„ ƒZ	edd„ ƒZ
edd„ ƒZedd„ ƒZedd„ ƒZedd„ ƒZedd„ ƒZedd„ ƒZedd„ ƒZedd„ ƒZedd„ ƒZed d!„ ƒZed"d#„ ƒZed$d%„ ƒZed&d'„ ƒZed(d)„ ƒZd*S )+ÚCommonFileMethodsa×  
    Abstract class for :doc:`uproot.reading.ReadOnlyFile` and
    :doc:`uproot.reading.DetachedFile`. The latter is a placeholder for file
    information, such as the :ref:`uproot.reading.CommonFileMethods.file_path`
    used in many error messages, without holding a reference to the active
    :doc:`uproot.source.chunk.Source`.

    This allows the file to be closed and deleted while objects that were read
    from it still exist. Also, only objects that hold detached file references,
    rather than active ones, can be pickled.

    The (unpickleable) objects that must hold a reference to an active
    :doc:`uproot.reading.ReadOnlyFile` are listed by C++ (decoded) classname
    in ``uproot.must_be_attached``.
    c                 C  s   | j S ©zw
        The original path to the file (converted to ``str`` if it was originally
        a ``pathlib.Path``).
        )Ú
_file_pathr.   r#   r#   r$   r    Ñ   s    zCommonFileMethods.file_pathc                 C  s   | j S )a¿  
        The dict of ``options`` originally passed to the file constructor.

        If this is a :doc:`uproot.writing.writable.WritableFile`, the ``options`` are a copy
        of the current state of the options; change the properties (e.g.
        ``initial_directory_bytes``, ``uuid_function``) directly on the file object
        to make a lasting change. Modifying the copied dict does not change the
        file's future behavior.
        )Ú_optionsr.   r#   r#   r$   r   Ù   s    zCommonFileMethods.optionsc                 C  s   dj | jŽ S )zË
        Version of ROOT used to write the file as a string.

        See :ref:`uproot.reading.CommonFileMethods.root_version_tuple` and
        :ref:`uproot.reading.CommonFileMethods.fVersion`.
        z{}.{:02d}/{:02d})ÚformatÚroot_version_tupler.   r#   r#   r$   Úroot_versionæ   s    zCommonFileMethods.root_versionc                 C  s@   | j }|dkr|d8 }|d }|d; }|d }|d; }|||fS )zÄ
        Version of ROOT used to write teh file as a tuple.

        See :ref:`uproot.reading.CommonFileMethods.root_version` and
        :ref:`uproot.reading.CommonFileMethods.fVersion`.
        é@B i'  r   ©Ú	_fVersion)r/   ÚversionÚmajorÚminorr#   r#   r$   r;   ð   s    z$CommonFileMethods.root_version_tuplec                 C  s
   | j dkS )aÈ  
        True if the ROOT file is 64-bit ready; False otherwise.

        A file that is larger than 4 GiB must be 64-bit ready, though any file
        might be. This refers to seek points like
        :ref:`uproot.reading.ReadOnlyFile.fSeekFree` being 64-bit integers,
        rather than 32-bit.

        Note that a file being 64-bit is distinct from a ``TDirectory`` being
        64-bit; see :ref:`uproot.reading.ReadOnlyDirectory.is_64bit`.
        r=   r>   r.   r#   r#   r$   Úis_64bit  s    zCommonFileMethods.is_64bitc                 C  s   t jj | j¡S )ai  
        A :doc:`uproot.compression.Compression` object describing the
        compression setting for the ROOT file.

        Note that different objects (even different ``TBranches`` within a
        ``TTree``) can be compressed differently, so this file-level
        compression is only a strong hint of how the objects are likely to
        be compressed.

        For some versions of ROOT ``TStreamerInfo`` is always compressed with
        :doc:`uproot.compression.ZLIB`, even if the compression is set to a
        different algorithm.

        See :ref:`uproot.reading.CommonFileMethods.fCompress`.
        )r   ÚcompressionZCompressionZ	from_codeÚ
_fCompressr.   r#   r#   r$   rD     s    zCommonFileMethods.compressionc              	   C  sR   d  dd„ | jD ƒ¡}d  |dd… |dd… |dd… |dd	… |d	d
… g¡S )zß
        The unique identifier (UUID) of the ROOT file expressed as a hexadecimal
        string.

        See :ref:`uproot.reading.CommonFileMethods.uuid` and
        :ref:`uproot.reading.CommonFileMethods.fUUID`.
        Ú c                 s  s   | ]}|d ›V  qdS )Ú02xNr#   ©Ú.0Úxr#   r#   r$   Ú	<genexpr>.  ó    z-CommonFileMethods.hex_uuid.<locals>.<genexpr>ú-r   é   é   é   é   é    )ÚjoinÚ_fUUID)r/   Úoutr#   r#   r$   Úhex_uuid%  s    	zCommonFileMethods.hex_uuidc                 C  s   t  | j dd¡¡S )zì
        The unique identifier (UUID) of the ROOT file expressed as a Python
        ``uuid.UUID`` object.

        See :ref:`uproot.reading.CommonFileMethods.hex_uuid` and
        :ref:`uproot.reading.CommonFileMethods.fUUID`.
        rM   rF   )ÚuuidÚUUIDrV   Úreplacer.   r#   r#   r$   rW   1  s    	zCommonFileMethods.uuidc                 C  s   | j S )a  
        Raw version information for the ROOT file; this number is used to derive
        :ref:`uproot.reading.CommonFileMethods.root_version`,
        :ref:`uproot.reading.CommonFileMethods.root_version_tuple`, and
        :ref:`uproot.reading.CommonFileMethods.is_64bit`.
        r>   r.   r#   r#   r$   ÚfVersion<  s    zCommonFileMethods.fVersionc                 C  s   | j S )zn
        The seek point (int) for the first data record, past the TFile header.

        Usually 100.
        )Ú_fBEGINr.   r#   r#   r$   ÚfBEGINF  s    zCommonFileMethods.fBEGINc                 C  s   | j S )zY
        The seek point (int) to the last free word at the end of the ROOT file.
        )Ú_fENDr.   r#   r#   r$   ÚfENDO  s    zCommonFileMethods.fENDc                 C  s   | j S )z�
        The seek point (int) to the ``TFree`` data, for managing empty spaces
        in a ROOT file (filesystem-like fragmentation).
        )Ú
_fSeekFreer.   r#   r#   r$   Ú	fSeekFreeV  s    zCommonFileMethods.fSeekFreec                 C  s   | j S )zŽ
        The number of bytes in the ``TFree`` data, for managing empty spaces
        in a ROOT file (filesystem-like fragmentation).
        )Ú_fNbytesFreer.   r#   r#   r$   ÚfNbytesFree^  s    zCommonFileMethods.fNbytesFreec                 C  s   | j S )z�
        The number of objects in the ``TFree`` data, for managing empty spaces
        in a ROOT file (filesystem-like fragmentation).
        )Ú_nfreer.   r#   r#   r$   Únfreef  s    zCommonFileMethods.nfreec                 C  s   | j S )zm
        The number of bytes in the filename (``TNamed``) that is embedded in
        the ROOT file.
        ©Ú_fNbytesNamer.   r#   r#   r$   ÚfNbytesNamen  s    zCommonFileMethods.fNbytesNamec                 C  s   | j S )zo
        Number of bytes in the serialization of file seek points, which can either
        be 4 or 8.
        )Ú_fUnitsr.   r#   r#   r$   ÚfUnitsv  s    zCommonFileMethods.fUnitsc                 C  s   | j S )aD  
        The raw integer describing the compression setting for the ROOT file.

        Note that different objects (even different ``TBranches`` within a
        ``TTree``) can be compressed differently, so this file-level
        compression is only a strong hint of how the objects are likely to
        be compressed.

        For some versions of ROOT ``TStreamerInfo`` is always compressed with
        :doc:`uproot.compression.ZLIB`, even if the compression is set to a
        different algorithm.

        See :ref:`uproot.reading.CommonFileMethods.compression`.
        )rE   r.   r#   r#   r$   Ú	fCompress~  s    zCommonFileMethods.fCompressc                 C  s   | j S )z�
        The seek point (int) to the ``TStreamerInfo`` data, where
        :ref:`uproot.reading.ReadOnlyFile.streamers` are located.
        )Ú
_fSeekInfor.   r#   r#   r$   Ú	fSeekInfo�  s    zCommonFileMethods.fSeekInfoc                 C  s   | j S )zŒ
        The number of bytes in the ``TStreamerInfo`` data, where
        :ref:`uproot.reading.ReadOnlyFile.streamers` are located.
        )Ú_fNbytesInfor.   r#   r#   r$   ÚfNbytesInfo˜  s    zCommonFileMethods.fNbytesInfoc                 C  s   | j S )zç
        The unique identifier (UUID) of the ROOT file as a raw bytestring
        (Python ``bytes``).

        See :ref:`uproot.reading.CommonFileMethods.hex_uuid` and
        :ref:`uproot.reading.CommonFileMethods.uuid`.
        )rT   r.   r#   r#   r$   ÚfUUID   s    	zCommonFileMethods.fUUIDN)r1   r2   r3   Ú__doc__Úpropertyr    r   r<   r;   rC   rD   rV   rW   rZ   r\   r^   r`   rb   rd   rg   ri   rj   rl   rn   ro   r#   r#   r#   r$   r6   À   sR   


	






	









r6   c                   @  s   e Zd ZdZdd„ ZdS )ÚDetachedFilea  
    Args:
        file (:doc:`uproot.reading.ReadOnlyFile`): The active file object to
            convert into a detached file.

    A placeholder for a :doc:`uproot.reading.ReadOnlyFile` with useful
    information, such as the :ref:`uproot.reading.CommonFileMethods.file_path`
    used in many error messages, without holding a reference to the active
    :doc:`uproot.source.chunk.Source`.

    This allows the file to be closed and deleted while objects that were read
    from it still exist. Also, only objects that hold detached file references,
    rather than active ones, can be pickled.

    The (unpickleable) objects that must hold a reference to an active
    :doc:`uproot.reading.ReadOnlyFile` are listed by C++ (decoded) classname
    in ``uproot.must_be_attached``.
    c                 C  s|   |j | _ |j| _|j| _|j| _|j| _|j| _|j| _|j| _|j| _|j	| _	|j
| _
|j| _|j| _|j| _|j| _d S r,   )r8   r9   r?   r[   r]   r_   ra   rc   rf   rh   rE   rk   rm   Ú_fUUID_versionrT   )r/   r"   r#   r#   r$   r0   À  s    zDetachedFile.__init__N)r1   r2   r3   rp   r0   r#   r#   r#   r$   rr   ¬  s   rr   z>4siiiiiiiBiiiH16sz>4siiqqiiiBiqiH16sc                   @  sª  e Zd ZdZddddddœddœdd	„Zd
d„ Zedd„ ƒZdd„ Zedd„ ƒZ	dd„ Z
dd„ Zedd„ ƒZedd„ ƒZejdd„ ƒZedd„ ƒZejdd„ ƒZedd„ ƒZdd ejfd!d"„Zed#d$„ ƒZed%d&„ ƒZd'd(„ ZdNd)d*„ZdOd+d,„Zed-d.„ ƒZejd/d.„ ƒZed0d1„ ƒZejd2d1„ ƒZed3d4„ ƒZejd5d4„ ƒZd6d7„ ZdPd8d9„Zd:d;„ Zed<d=„ ƒZd>d?„ Z d@dA„ Z!dBdC„ Z"dDdE„ Z#dFdG„ Z$dHdI„ Z%dJdK„ Z&dLdM„ Z'dS )Qr   aª  
    Args:
        file_path (str or ``pathlib.Path``): The filesystem path or remote URL
            of the file to open. Unlike :doc:`uproot.reading.open`, it cannot
            be followed by a colon (``:``) and an object path within the ROOT
            file.
        object_cache (None, MutableMapping, or int): Cache of objects drawn
            from ROOT directories (e.g histograms, TTrees, other directories);
            if None, do not use a cache; if an int, create a new cache of this
            size.
        array_cache (None, MutableMapping, or memory size): Cache of arrays
            drawn from ``TTrees``; if None, do not use a cache; if a memory size,
            create a new cache of this size.
        custom_classes (None or MutableMapping): If None, classes come from
            uproot.classes; otherwise, a container of class definitions that
            is both used to fill with new classes and search for dependencies.
        decompression_executor (None or Executor with a ``submit`` method): The
            executor that is used to decompress ``TBaskets``; if None, a
            :doc:`uproot.source.futures.TrivialExecutor` is created.
            Executors attached to a file are ``shutdown`` when the file is closed.
        interpretation_executor (None or Executor with a ``submit`` method): The
            executor that is used to interpret uncompressed ``TBasket`` data as
            arrays; if None, a :doc:`uproot.source.futures.TrivialExecutor`
            is created.
            Executors attached to a file are ``shutdown`` when the file is closed.
        options: See below.

    Handle to an open ROOT file, the way to access data in ``TDirectories``
    (:doc:`uproot.reading.ReadOnlyDirectory`) and create new classes from
    ``TStreamerInfo`` (:ref:`uproot.reading.ReadOnlyFile.streamers`).

    All objects derived from ROOT files have a pointer back to the file,
    though this is a :doc:`uproot.reading.DetachedFile` (no active connection,
    cannot read more data) if the object's :ref:`uproot.model.Model.classname`
    is not in ``uproot.reading.must_be_attached``: objects that can read
    more data and need to have an active connection (like ``TTree``,
    ``TBranch``, and ``TDirectory``).

    Note that a :doc:`uproot.reading.ReadOnlyFile` can't be directly used to
    extract objects. To read data, use the :doc:`uproot.reading.ReadOnlyDirectory`
    returned by :ref:`uproot.reading.ReadOnlyFile.root_directory`. This is why
    :doc:`uproot.reading.open` returns a :doc:`uproot.reading.ReadOnlyDirectory`
    and not a :doc:`uproot.reading.ReadOnlyFile`.

    Options (type; default):

    * handler (:doc:`uproot.source.chunk.Source` class; None)
    * timeout (float for HTTP, int for XRootD; 30)
    * max_num_elements (None or int; None)
    * num_workers (int; 1)
    * use_threads (bool; False on the emscripten platform (i.e. in a web browser), else True)
    * num_fallback_workers (int; 10)
    * begin_chunk_size (memory_size; 403, the smallest a ROOT file can be)
    * minimal_ttree_metadata (bool; True)

    See the `ROOT TFile documentation <https://root.cern.ch/doc/master/classTFile.html>`__
    for a specification of ``TFile`` header fields.
    r   r	   Nr
   zstr | Path | IO)r    c                K  sÂ  || _ || _|| _|| _|| _|| _tj ¡ | _	| j	 
|¡ dD ]}tj | j	| ¡| j	|< q@d | _d | _|  ¡  tj || j	¡\}	}|	|fi | j	¤Ž| _|  ¡  | j	d tjk rÊtd | j	d tj¡ƒ‚| j d| j	d ¡ ¡ | _|  ¡  tjj d¡ | jt i ¡\}
| _!| _"| _#| _$| _%| _&| _'| _(| _)| _*| _+| _,| _-| j.�r”tjj d¡ | jti ¡\}
| _!| _"| _#| _$| _%| _&| _'| _(| _)| _*| _+| _,| _-| j/|
d� |
dk�r¾td|
›d|› �ƒ‚d S )	N)r*   r*   z?begin_chunk_size={} is not enough to read the TFile header ({})r   )Úmagics   rootz&not a ROOT file: first four bytes are ú	
in file )0r8   r   r   r   r   r   r%   ÚdefaultsÚcopyr9   Úupdater   r   Zmemory_sizeÚ
_streamersÚ_streamer_rulesÚhook_before_create_sourceZfile_path_to_source_classÚ_sourceÚhook_before_get_chunksÚ_file_header_fields_bigÚsizer   r:   ÚchunkÚdetach_memmapÚ_begin_chunkÚhook_before_interpretÚsourceÚcursorÚCursorÚfieldsÚ_file_header_fields_smallr?   r[   r]   r_   ra   rc   rf   rh   rE   rk   rm   rs   rT   rC   Úhook_after_interpret)r/   r    r   r   r   r   r   r   ÚoptionZ
source_clsrt   r#   r#   r$   r0     s’    ÿþÿ
ÿ
ÿñÿñ
ÿÿzReadOnlyFile.__init__c                 C  s   d| j ›dt| ƒd›d�S )Nz<ReadOnlyFile z at 0xÚ012xú>)r8   Úidr.   r#   r#   r$   Ú__repr__r  s    zReadOnlyFile.__repr__c                 C  s   t | ƒS )zL
        A :doc:`uproot.reading.DetachedFile` version of this file.
        )rr   r.   r#   r#   r$   Údetachedu  s    zReadOnlyFile.detachedc                 C  sF   | j  ¡  t| jdƒr&t| jddƒƒ  t| jdƒrBt| jddƒƒ  dS )aÒ  
        Explicitly close the file.

        (Files can also be closed with the Python ``with`` statement, as context
        managers.)

        After closing, new objects and classes cannot be extracted from the file,
        but objects with :doc:`uproot.reading.DetachedFile` references instead
        of :doc:`uproot.reading.ReadOnlyFile` that are still in the
        :ref:`uproot.reading.ReadOnlyFile.object_cache` would still be
        accessible.
        ÚshutdownN)r|   Úcloser   Ú_decompression_executorÚgetattrÚ_interpretation_executorr.   r#   r#   r$   r‘   |  s
    
zReadOnlyFile.closec                 C  s   | j jS )a;  
        True if the file has been closed; False otherwise.

        The file may have been closed explicitly with
        :ref:`uproot.reading.ReadOnlyFile.close` or implicitly in the Python
        ``with`` statement, as a context manager.

        After closing, new objects and classes cannot be extracted from the file,
        but objects with :doc:`uproot.reading.DetachedFile` references instead
        of :doc:`uproot.reading.ReadOnlyFile` that are still in the
        :ref:`uproot.reading.ReadOnlyFile.object_cache` would still be
        accessible.
        )r|   Úclosedr.   r#   r#   r$   r•   �  s    zReadOnlyFile.closedc                 C  s   | j  ¡  | S r,   )r|   Ú	__enter__r.   r#   r#   r$   r–      s    
zReadOnlyFile.__enter__c                 C  sL   | j  |||¡ t| jdƒr,t| jdd ƒƒ  t| jdƒrHt| jdd ƒƒ  d S )Nr�   )r|   Ú__exit__r   r’   r“   r”   ©r/   Zexception_typeZexception_valueÚ	tracebackr#   r#   r$   r—   ¤  s
    zReadOnlyFile.__exit__c                 C  s   | j S )a  
        The :doc:`uproot.source.chunk.Source` associated with this file, which
        is the "physical layer" that knows how to communicate with local file
        systems or through remote protocols like HTTP(S) or XRootD, but does not
        know what the bytes mean.
        )r|   r.   r#   r#   r$   r„   «  s    zReadOnlyFile.sourcec                 C  s   | j S )aZ  
        A cache used to hold previously extracted objects, so that code like

        .. code-block:: python

            h = my_file["histogram"]
            h = my_file["histogram"]
            h = my_file["histogram"]

        only reads the ``"histogram"`` once.

        Any Python ``MutableMapping`` can be used as a cache (i.e. a Python
        dict would be a cache that never evicts old objects), though
        :doc:`uproot.cache.LRUCache` is a good choice because it is thread-safe
        and evicts least-recently used objects when a maximum number of objects
        is reached.
        )Ú_object_cacher.   r#   r#   r$   r   µ  s    zReadOnlyFile.object_cachec                 C  sB   |d u st |tƒr|| _n$tj |¡r6tj |¡| _ntdƒ‚d S )Nz6object_cache must be None, a MutableMapping, or an int)	r   r   rš   r   r   ÚisintÚcacheZLRUCacheÚ	TypeError©r/   Úvaluer#   r#   r$   r   Ê  s
    c                 C  s   | j S )a[  
        A cache used to hold previously extracted arrays, so that code like

        .. code-block:: python

            a = my_tree["branch"].array()
            a = my_tree["branch"].array()
            a = my_tree["branch"].array()

        only reads the ``"branch"`` once.

        Any Python ``MutableMapping`` can be used as a cache (i.e. a Python
        dict would be a cache that never evicts old objects), though
        :doc:`uproot.cache.LRUArrayCache` is a good choice because it is
        thread-safe and evicts least-recently used objects when a size limit is
        reached.
        )Ú_array_cacher.   r#   r#   r$   r   Ó  s    zReadOnlyFile.array_cachec                 C  sL   |d u st |tƒr|| _n.tj |¡s0t |tƒr@tj |¡| _nt	dƒ‚d S )Nz<array_cache must be None, a MutableMapping, or a memory size)
r   r   r    r   r   r›   r   rœ   ZLRUArrayCacher�   rž   r#   r#   r$   r   è  s    ÿc                 C  s"   t dtjj | j| j ¡i | | ƒS )zh
        The root ``TDirectory`` of the file
        (:doc:`uproot.reading.ReadOnlyDirectory`).
        r#   )ÚReadOnlyDirectoryr   r„   r…   r†   r[   rf   r.   r#   r#   r$   r   ó  s    ûzReadOnlyFile.root_directoryÚmaxc           
      C  s¨   t j |¡}|du rFg }| j ¡ D ] \}}|D ]}| ||f¡ q.q"n| j||d�}d}|D ]F\}}| j|  ¡ D ].\}}	||krr|s�| d¡ |	j|d� d}qrq\dS )ac  
        Args:
            classname (None or str): If None, all streamers that are
                defined in the file are shown; if a class name, only
                this class and its dependencies are shown.
            version (int, "min", or "max"): Version number of the desired
                class; "min" or "max" returns the minimum or maximum version
                number, respectively.
            stream (object with a ``write(str)`` method): Stream to write the
                output to.

        Interactively display a file's ``TStreamerInfo``.

        Example with ``classname="TLorentzVector"``:

        .. code-block::

            TVector3 (v3): TObject (v1)
                fX: double (TStreamerBasicType)
                fY: double (TStreamerBasicType)
                fZ: double (TStreamerBasicType)

            TObject (v1)
                fUniqueID: unsigned int (TStreamerBasicType)
                fBits: unsigned int (TStreamerBasicType)

            TLorentzVector (v4): TObject (v1)
                fP: TVector3 (TStreamerObject)
                fE: double (TStreamerBasicType)
        N©r@   TÚ
)ÚstreamF)	r   ÚmodelÚclassname_regularizeÚ	streamersr   ÚappendÚstreamer_dependenciesÚwriteÚshow)
r/   Ú	classnamer@   r¥   ÚnamesÚnameÚstreamer_versionsÚfirstÚvÚstreamerr#   r#   r$   Úshow_streamers  s    
zReadOnlyFile.show_streamersc                   s¸  ddl ‰ ddl‰ ddl‰ ddl‰ | jdu �r²| jdkr@i | _�nrˆ jj | j¡}| j}t	| jt
j | jƒ}|  ||¡}| j||d� t||i | | ƒ}| j|||d� | ¡ \}}| j|||||d� ˆ j d| j¡}|d  ||i | | jd¡}	i | _g | _|	D ]ž}
t|
ˆ jjƒ�r@|
j| jv�r,i | j|
j< |
| j|
j |
j< qþt|
ˆ jjj ƒ�r‚t!‡ fdd„|
D ƒƒ�r‚| j "d	d
„ |
D ƒ¡ qþt#dt$|
ƒ› d| j%› �ƒ‚qþ| j&|||||d� | jS )aU  
        A list of :doc:`uproot.streamers.Model_TStreamerInfo` objects
        representing the ``TStreamerInfos`` in the ROOT file.

        A file's ``TStreamerInfos`` are only read the first time they are needed.
        Uproot has a suite of predefined models in ``uproot.models`` to reduce
        the probability that ``TStreamerInfos`` will need to be read (depending
        on the choice of classes or versions of the classes that are accessed).

        See also :ref:`uproot.reading.ReadOnlyFile.streamer_rules`, which are
        read in the same pass with ``TStreamerInfos``.
        r   N)Ú	key_chunkÚ
key_cursor)rµ   r¶   Ústreamer_key)rµ   r¶   r·   Ústreamer_cursorÚstreamer_chunkÚTListc                 3  s   | ]}t |ˆ jjjƒV  qd S r,   )r   ÚmodelsZ
TObjStringZModel_TObjString©rI   Úy©r   r#   r$   rK   z  s   ÿz)ReadOnlyFile.streamers.<locals>.<genexpr>c                 S  s   g | ]}t |ƒ‘qS r#   )r   r¼   r#   r#   r$   Ú
<listcomp>~  rL   z*ReadOnlyFile.streamers.<locals>.<listcomp>z:unexpected type in TList of streamers and streamer rules: ru   )'Zuproot.models.TListZuproot.models.TObjArrayZuproot.models.TObjStringZuproot.streamersry   rk   r„   r…   r†   ÚminÚ_key_format_bigr   r]   r€   Úhook_before_read_streamer_keyÚReadOnlyKeyÚ%hook_before_read_decompress_streamersÚget_uncompressed_chunk_cursorÚhook_before_interpret_streamersr¦   Úmaybe_custom_classesÚ_custom_classesr   r�   rz   r   r¨   ZModel_TStreamerInfor¯   Úclass_versionr»   rº   ZModel_TListÚallÚextendr   Útyper8   Úhook_after_interpret_streamers)r/   r¶   Z	key_startZkey_stoprµ   r·   r¹   r¸   ÚclassesZtlistrJ   r#   r¾   r$   r¨   1  s|    

þý	ýûÿÿþ
ÿÿûzReadOnlyFile.streamersc                 C  s   | j du r| j | j S )a¾  
        A list of strings of C++ code that help schema evolution of
        ``TStreamerInfo`` by providing rules to evaluate when new objects are
        accessed by old ROOT versions.

        Uproot does not evaluate these rules because they are written in C++ and
        Uproot does not have access to a C++ compiler.

        These rules are read in the same pass that produces
        :ref:`uproot.reading.ReadOnlyFile.streamers`.
        N)rz   r¨   r.   r#   r#   r$   Ústreamer_rules�  s    
zReadOnlyFile.streamer_rulesc                 C  s4   t j |¡}| j |¡}|du r$g S t| ¡ ƒS dS )aÖ  
        Returns a list of :doc:`uproot.streamers.Model_TStreamerInfo` objects
        that match C++ (decoded) ``classname``.

        More that one streamer matching a given name is unlikely, but possible
        because there may be different versions of the same class. (Perhaps such
        files can be created by merging data from different ROOT versions with
        hadd?)

        See also :ref:`uproot.reading.ReadOnlyFile.streamer_named` (singular).
        N)r   r¦   r§   r¨   ÚgetÚlistÚvalues)r/   r­   r°   r#   r#   r$   Ústreamers_named¡  s
    zReadOnlyFile.streamers_namedc                 C  sf   t j |¡}| j |¡}|du s,t|ƒdkr0dS |dkrD|t|ƒ S |dkrX|t|ƒ S | |¡S dS )a¹  
        Returns a single :doc:`uproot.streamers.Model_TStreamerInfo` object
        that matches C++ (decoded) ``classname`` and ``version``.

        The ``version`` can be an integer or ``"min"`` or ``"max"`` for the
        minimum and maximum version numbers available in the file. The default
        is ``"max"`` because there's usually only one.

        See also :ref:`uproot.reading.ReadOnlyFile.streamers_named` (plural).
        Nr   rÀ   r¢   )r   r¦   r§   r¨   rÐ   r   rÀ   r¢   )r/   r­   r@   r°   r#   r#   r$   Ústreamer_named´  s    zReadOnlyFile.streamer_namedc           	      C  sö   t j |¡}|dkr¼|  |¡}|jdd„ d� g }|D ]€}g }| | j|¡ |ddd… D ]Z}||vrZtdt|ƒ d dƒD ],}|| d |d kr|| 	|d |¡  qZq|| 
|¡ qZq6|S | j||d	�}g }|durä| | j|¡ |ddd… S dS )
a>  
        Returns a list of :doc:`uproot.streamers.Model_TStreamerInfo` objects
        that depend on the one that matches C++ (decoded) ``classname`` and
        ``version``.

        The ``classname`` and ``version`` are interpreted the same way as
        :ref:`uproot.reading.ReadOnlyFile.streamer_named`.
        rÊ   c                 S  s   | j  S r,   )rÉ   )rJ   r#   r#   r$   Ú<lambda>×  rL   z4ReadOnlyFile.streamer_dependencies.<locals>.<lambda>)ÚkeyNéÿÿÿÿr   r   r£   )r   r¦   r§   rÓ   ÚsortZ_dependenciesr¨   Úranger   Úinsertr©   rÔ   )	r/   r­   r@   r¨   rU   r³   ÚbatchrJ   Úir#   r#   r$   rª   Ê  s*    	
z"ReadOnlyFile.streamer_dependenciesc                 C  s   | j S )z…
        Either a dict of class objects specific to this file or None if it uses
        the common ``uproot.classes`` pool.
        )rÈ   r.   r#   r#   r$   r   í  s    zReadOnlyFile.custom_classesc                 C  s&   |d u st |tƒr|| _ntdƒ‚d S )Nz/custom_classes must be None or a MutableMapping)r   r   rÈ   r�   rž   r#   r#   r$   r   õ  s    c                 C  s   | j S )al  
        An object satisfying the Executor interface; ``submit(task, *args, **kwargs)``
        returns a Future, which blocks and returns ``task(*args, **kwargs)`` when
        its ``Future.result()`` is called.

        This executor is used to decompress ``TBasket`` data.

        Executors attached to a file are ``shutdown`` when the file is closed.
        )r’   r.   r#   r#   r$   r   ü  s    z#ReadOnlyFile.decompression_executorc                 C  s0   |d u rt jj ¡ }t|dƒs&tdƒ‚|| _d S )NÚsubmitz2decompression_executor must have a 'submit' method)r   r„   ÚfuturesÚTrivialExecutorr   r�   r’   rž   r#   r#   r$   r   	  s
    
c                 C  s   | j S )a„  
        An object satisfying the Executor interface; ``submit(task, *args, **kwargs)``
        returns a Future, which blocks and returns ``task(*args, **kwargs)`` when
        its ``Future.result()`` is called.

        This executor is used to interpret arrays from uncompressed ``TBasket`` data.

        Executors attached to a file are ``shutdown`` when the file is closed.
        )r”   r.   r#   r#   r$   r     s    z$ReadOnlyFile.interpretation_executorc                 C  s0   |d u rt jj ¡ }t|dƒs&tdƒ‚|| _d S )NrÝ   z3interpretation_executor must have a 'submit' method)r   r„   rÞ   rß   r   r�   r”   rž   r#   r#   r$   r     s
    
c                 C  s8   t j |¡}| jdu r"tt jƒ| _|| jv r4| j|= dS )að  
        Removes all versions of a class, specified by C++ (decoded)
        ``classname``, from the :ref:`uproot.reading.ReadOnlyFile.custom_classes`.

        If the file doesn't have a
        :ref:`uproot.reading.ReadOnlyFile.custom_classes`, this function adds
        one, so it does not remove the class from the common pool.

        If you want to remove a class from the common pool, you can do so with

        .. code-block:: python

            del uproot.classes[classname]
        N)r   r¦   r§   rÈ   r   rÎ   )r/   r­   r#   r#   r$   Úremove_class_definition&  s
    

z$ReadOnlyFile.remove_class_definitionc           	      C  s  t j |¡}t j || j¡}| |¡}|du rZ|  |¡}t|ƒdkrZ| jdurZt j |¡}|du rŠt	 
d|¡durŠt jj |¡}d|_|S |du �rt|ƒdkrät j |¡}|du ràt j t jj|dd�t jjfi ¡}|t j|< |S t j t j t j |¡¡t jjfdi i¡}|||< |du�rt|t jjƒ�rt j |¡�sð|  ||¡}|du�r\|j}n”|dk�r‚t|jƒdk�r‚t|jƒ}nn|d	k�r¨t|jƒdk�r¨t|jƒ}nHt j |¡}|du �rìt j t jj||dd�t jjfi ¡}|t j|< |S | |¡}|du �r| | |¡}n|}|S )
aì  
        Returns or creates a class with a given C++ (decoded) ``classname``
        and possible ``version``.

        * If the ``version`` is None, this function may return a
          :doc:`uproot.model.DispatchByVersion`.
        * If the ``version`` is an integer, ``"min"`` or ``"max"``, then it
          returns a :doc:`uproot.model.VersionedModel`. Using ``"min"`` or
          ``"max"`` specifies the minium or maximum version ``TStreamerInfo``
          defined by the file; most files define only one so ``"max"`` is
          usually safe.

        If this file has :ref:`uproot.reading.ReadOnlyFile.custom_classes`,
        the new class is added to that dict; otherwise, it is added to the
        global ``uproot.classes``.
        Nr   z.(std\s*::\s*)?(vector|list|map|set|bitset)\s*<FT)ÚunknownÚknown_versionsr¢   rÀ   )r   r¦   r§   rÇ   rÈ   rÐ   rÓ   r   rÎ   ÚreÚmatchZinterpretationÚidentifyZparse_typenameZ_headerZunknown_classesr   Ú	new_classÚclassname_encodeZUnknownClassÚ
ensure_strZDispatchByVersionÚ
issubclassr›   rÔ   rÉ   râ   r¢   rÀ   ZUnknownClassVersionZclass_of_version)	r/   r­   r@   rÎ   Úclsr¨   Zunknown_clsr³   Zversioned_clsr#   r#   r$   Úclass_named;  st    

ÿ
ÿþ
ý
ý

ÿû


zReadOnlyFile.class_namedc                 C  s@   | j rtd| j›d�ƒ‚n"||f| jv r.| jS | j ||¡S dS )aß  
        Returns a :doc:`uproot.source.chunk.Chunk` from the
        :doc:`uproot.source.chunk.Source` that is guaranteed to include bytes
        from ``start`` up to ``stop`` seek points in the file.

        If the desired range is satisfied by a previously saved chunk, such as
        :ref:`uproot.reading.ReadOnlyFile.begin_chunk`, then that is returned.
        Hence, the returned chunk may include more data than the range from
        ``start`` up to ``stop``.
        zfile z
 is closedN)r•   ÚOSErrorr8   r‚   r|   r€   )r/   ÚstartÚstopr#   r#   r$   r€   ‘  s
    zReadOnlyFile.chunkc                 C  s   | j S )zµ
        A special :doc:`uproot.source.chunk.Chunk` corresponding to the
        beginning of the file, from seek point ``0`` up to
        ``options["begin_chunk_size"]``.
        )r‚   r.   r#   r#   r$   Úbegin_chunk£  s    zReadOnlyFile.begin_chunkc                 K  s   dS )zõ
        Called in the :doc:`uproot.reading.ReadOnlyFile` constructor before the
        :doc:`uproot.source.chunk.Source` is created.

        This is the first hook called in the :doc:`uproot.reading.ReadOnlyFile`
        constructor.
        Nr#   ©r/   Úkwargsr#   r#   r$   r{   ¬  s    z&ReadOnlyFile.hook_before_create_sourcec                 K  s   dS )a!  
        Called in the :doc:`uproot.reading.ReadOnlyFile` constructor after the
        :doc:`uproot.source.chunk.Source` is created but before attempting to
        get any :doc:`uproot.source.chunk.Chunk`, specifically the
        :ref:`uproot.reading.ReadOnlyFile.begin_chunk`.
        Nr#   rð   r#   r#   r$   r}   µ  s    z#ReadOnlyFile.hook_before_get_chunksc                 K  s   dS )zÍ
        Called in the :doc:`uproot.reading.ReadOnlyFile` constructor after
        loading the :ref:`uproot.reading.ReadOnlyFile.begin_chunk` and before
        interpreting its ``TFile`` header.
        Nr#   rð   r#   r#   r$   rƒ   ½  s    z"ReadOnlyFile.hook_before_interpretc                 K  s   dS )a4  
        Called in the :doc:`uproot.reading.ReadOnlyFile` constructor after
        interpreting the ``TFile`` header and before raising an error if
        the first four bytes are not ``b"root"``.

        This is the last hook called in the :doc:`uproot.reading.ReadOnlyFile`
        constructor.
        Nr#   rð   r#   r#   r$   r‰   Ä  s    z!ReadOnlyFile.hook_after_interpretc                 K  s   dS )zó
        Called in :ref:`uproot.reading.ReadOnlyFile.streamers` before reading
        the ``TKey`` associated with the ``TStreamerInfo``.

        This is the first hook called in
        :ref:`uproot.reading.ReadOnlyFile.streamers`.
        Nr#   rð   r#   r#   r$   rÂ   Î  s    z*ReadOnlyFile.hook_before_read_streamer_keyc                 K  s   dS )zÚ
        Called in :ref:`uproot.reading.ReadOnlyFile.streamers` after reading
        the ``TKey`` associated with the ``TStreamerInfo`` and before reading
        and decompressing the ``TStreamerInfo`` data.
        Nr#   rð   r#   r#   r$   rÄ   ×  s    z2ReadOnlyFile.hook_before_read_decompress_streamersc                 K  s   dS )z°
        Called in :ref:`uproot.reading.ReadOnlyFile.streamers` after reading
        and decompressing the ``TStreamerInfo`` data, but before interpreting
        it.
        Nr#   rð   r#   r#   r$   rÆ   Þ  s    z,ReadOnlyFile.hook_before_interpret_streamersc                 K  s   dS )zÞ
        Called in :ref:`uproot.reading.ReadOnlyFile.streamers` after
        interpreting the ``TStreamerInfo`` data.

        This is the last hook called in
        :ref:`uproot.reading.ReadOnlyFile.streamers`.
        Nr#   rð   r#   r#   r$   rÍ   å  s    z+ReadOnlyFile.hook_after_interpret_streamers)r¢   )r¢   )N)(r1   r2   r3   rp   r0   rŽ   rq   r�   r‘   r•   r–   r—   r„   r   Úsetterr   r   ÚsysÚstdoutr´   r¨   rÏ   rÓ   rÔ   rª   r   r   r   rà   rë   r€   rï   r{   r}   rƒ   r‰   rÂ   rÄ   rÆ   rÍ   r#   r#   r#   r$   r   Ö  sx   ?ø`


	





0
^


#






V
	
	r   z	>hIIiiiiiz	>hIIiiqqqz>ic                   @  sH  e Zd ZdZdd„ Zdd„ Zedd„ ƒZedd	„ ƒZed
d„ ƒZ	edd„ ƒZ
dd„ Zedd„ ƒZdd„ Zdd„ Zedd„ ƒZedd„ ƒZedd„ ƒZedd„ ƒZedd„ ƒZed d!„ ƒZd"d"eed#œd$d%„Zd"eed&œd'd(„Zd"d"eed#œd)d*„Zd"d"eed#œd+d,„Zd"d"eed#œd-d.„Zd"eed&œd/d0„Zd"d"eed#œd1d2„Zd"d"eed#œd3d4„Zd5d6„ Zd7d8„ Zd9d:„ Z d;d<„ Z!d=d>„ Z"djd?d@„Z#dkdCdD„Z$dldEdF„Z%dmdHdI„Z&dJdK„ Z'dLdM„ Z(edNdO„ ƒZ)edPdQ„ ƒZ*edRdS„ ƒZ+edTdU„ ƒZ,edVdW„ ƒZ-edXdY„ ƒZ.edZd[„ ƒZ/ed\d]„ ƒZ0d^d_„ Z1d`da„ Z2dbdc„ Z3ddde„ Z4dfdg„ Z5dhdi„ Z6dBS )nr¡   a–  
    Args:
        path (tuple of str): Object path of the ``TDirectory`` as a tuple of
            nested ``TDirectory`` names.
        cursor (:doc:`uproot.source.cursor.Cursor`): Current position in
            the :doc:`uproot.reading.ReadOnlyFile`.
        context (dict): Auxiliary data used in deserialization.
        file (:doc:`uproot.reading.ReadOnlyFile`): The open file object.
        parent (None or calling object): The previous ``read`` in the
            recursive descent.

    Represents a ``TDirectory`` from a ROOT file, most notably, the root
    directory (:ref:`uproot.reading.ReadOnlyFile.root_directory`).

    Be careful not to confuse :doc:`uproot.reading.ReadOnlyFile` and
    :doc:`uproot.reading.ReadOnlyDirectory`: files are for accessing global
    information such as :ref:`uproot.reading.ReadOnlyFile.streamers` and
    directories are for data in local hierarchies.

    A :doc:`uproot.reading.ReadOnlyDirectory` is a Python ``Mapping``, which
    uses square bracket syntax to extract objects:

    .. code-block:: python

        my_directory["histogram"]
        my_directory["tree"]
        my_directory["directory"]["another_tree"]

    Objects in ROOT files also have "cycle numbers," which allow multiple
    versions of an object to be retrievable using the same name. A cycle number
    may be specified after a semicolon:

    .. code-block:: python

        my_directory["histogram;2"]

    but without one, the directory defaults to the latest (highest cycle number).

    It's also possible to navigate through nested directories with a slash (``/``)
    instead of sequences of square brackets. The following are equivalent:

    .. code-block:: python

        my_directory["directory"]["another_tree"]["branch_in_tree"]  # long form
        my_directory["directory/another_tree"]["branch_in_tree"]     # / for dir
        my_directory["directory/another_tree/branch_in_tree"]        # / for branch
        my_directory["/directory/another_tree/branch_in_tree"]       # absolute
        my_directory["/directory////another_tree/branch_in_tree"]    # extra ///

    As a Python ``Mapping``, :doc:`uproot.reading.ReadOnlyDirectory` also has

    * :ref:`uproot.reading.ReadOnlyDirectory.keys`: names of objects in the
      ``TDirectory``
    * :ref:`uproot.reading.ReadOnlyDirectory.values`: objects in the
      ``TDirectory``
    * :ref:`uproot.reading.ReadOnlyDirectory.items`: 2-tuple (name, object)
      pairs.

    However, the :doc:`uproot.reading.ReadOnlyDirectory` versions of these
    methods have extra parameters for navigating a complex ROOT file. In addition,
    there is a

    * :ref:`uproot.reading.ReadOnlyDirectory.classnames`: returns a dict of
      (name, classname) pairs.

    with the same parameters.

    See the `ROOT TDirectoryFile documentation <https://root.cern.ch/doc/master/classTDirectoryFile.html>`__
    for a specification of ``TDirectory`` header fields (in an image).
    c              	   C  s$  || _ | ¡ | _|| _|| _| j|d� |j}t|tj	 |j
ƒ}| ||¡}| j||d� |j|t|dd�\| _| _| _| _| _| _| _| _| jrÂ| |t|¡\| _| _| _| _| _| _| _| _n| tj	¡ | jdkrôd | _g | _i | _d | _�n,| j}	t|	| j d |j
ƒ}
tjj  | j¡}| j!|||d� |	|
f|v �rD|}n| |	|
¡}| j"||||d� t#||i || d	d
� | $|t%|¡}| j&|||||d� g | _i | _t'|ƒD ]X}t#||i || d	d
�}|j(}|| jv�ràg | j|< | j|  )t*| jƒ¡ | j )|¡ �q¬d | _| j+|||||d� d S )N)r…   )r€   r…   F©Úmover   rN   )r€   r…   Úkeys_cursor)r€   r…   Ú
keys_chunkr÷   T)Úread_strings)r€   r…   rø   r÷   Únum_keys),Ú_pathrw   Ú_cursorÚ_fileÚ_parentÚhook_before_readÚindexrÀ   Ú_directory_format_bigr   r^   r€   rƒ   r‡   Ú_directory_format_smallr?   Ú	_fDatimeCÚ	_fDatimeMÚ_fNbytesKeysrf   Ú	_fSeekDirÚ_fSeekParentÚ
_fSeekKeysrC   ÚskipZ_header_keyÚ_keysÚ_keys_lookupÚ_lenr   r„   r…   r†   Úhook_before_read_keysÚhook_before_header_keyrÃ   ÚfieldÚ_directory_format_num_keysÚhook_before_keysrÙ   ÚfNamer©   r   Úhook_after_keys)r/   r   r…   Úcontextr"   ÚparentZdirectory_startZdirectory_stopr€   Z
keys_startZ	keys_stopr÷   rø   rú   Ú_rÖ   r¯   r#   r#   r$   r0   <  s¤    
÷
÷ø

ÿüÿûÿ
ûzReadOnlyDirectory.__init__c                 C  s    d  tdd | j¡ ƒt| ƒ¡S )Nz#<ReadOnlyDirectory {} at 0x{:012x}>ú/)r:   ÚreprrS   rû   r�   r.   r#   r#   r$   rŽ   ¦  s    ÿzReadOnlyDirectory.__repr__c                 C  s   | j S )z÷
        Object path of the ``TDirectory`` as a tuple of nested ``TDirectory``
        names. The root directory is an empty tuple, ``()``.

        See :ref:`uproot.reading.ReadOnlyDirectory.object_path` for the path
        as a string.
        )rû   r.   r#   r#   r$   r   «  s    	zReadOnlyDirectory.pathc                 C  s    d  dg| j¢d‘R ¡ dd¡S )a  
        Object path of the ``TDirectory`` as a single string, beginning and
        ending with ``/``. The root directory is a single slash, ``"/"``.

        See :ref:`uproot.reading.ReadOnlyDirectory.path` for the path as a
        tuple of strings.
        r  rF   z//)rS   rû   rY   r.   r#   r#   r$   r!   ¶  s    	zReadOnlyDirectory.object_pathc                 C  s   | j jS r7   )rý   r    r.   r#   r#   r$   r    Á  s    zReadOnlyDirectory.file_pathc                 C  s   | j S )aB  
        The :doc:`uproot.reading.ReadOnlyFile` in which this ``TDirectory``
        resides.

        This property is useful for getting global information, in idioms like

        .. code-block:: python

            with uproot.open("/path/to/file.root") as handle:
                handle.file.show_streamers()
        ©rý   r.   r#   r#   r$   r"   É  s    zReadOnlyDirectory.filec                 C  s   | j  ¡  dS )zl
        Close the :doc:`uproot.reading.ReadOnlyFile` in which this ``TDirectory``
        resides.
        N)rý   r‘   r.   r#   r#   r$   r‘   Ø  s    zReadOnlyDirectory.closec                 C  s   | j jS )zn
        True if the :ref:`uproot.reading.ReadOnlyDirectory.file` is closed;
        False otherwise.
        )rý   r•   r.   r#   r#   r$   r•   ß  s    zReadOnlyDirectory.closedc                 C  s   | j j ¡  | S r,   )rý   r„   r–   r.   r#   r#   r$   r–   ç  s    zReadOnlyDirectory.__enter__c                 C  s   | j j |||¡ d S r,   )rý   r„   r—   r˜   r#   r#   r$   r—   ë  s    zReadOnlyDirectory.__exit__c                 C  s   t j | j¡S )zª
        Creation date/time as a Python datetime.

        :ref:`uproot.reading.ReadOnlyDirectory.fDatimeC` presents this in ROOT's
        raw integer encoding.
        )r   r   Úcode_to_datetimer  r.   r#   r#   r$   Ú
created_onî  s    zReadOnlyDirectory.created_onc                 C  s   t j | j¡S )z®
        Modification date/time as a Python datetime.

        :ref:`uproot.reading.ReadOnlyDirectory.fDatimeM` presents this in ROOT's
        raw integer encoding.
        )r   r   r  r  r.   r#   r#   r$   Úmodified_onø  s    zReadOnlyDirectory.modified_onc                 C  s   | j S )z¿
        A :doc:`uproot.source.cursor.Cursor` pointing to the seek point in the
        file where this ``TDirectory`` is defined (at the start of the
        ``TDirectory`` header).
        ©rü   r.   r#   r#   r$   r…     s    zReadOnlyDirectory.cursorc                 C  s   | j S ©zž
        The object that was deserialized before this one in recursive descent,
        usually the containing object (or the container's container).
        ©rþ   r.   r#   r#   r$   r    s    zReadOnlyDirectory.parentc                 C  s
   | j dkS )as  
        True if the ``TDirectory`` is 64-bit ready; False otherwise.

        This refers to seek points like
        :ref:`uproot.reading.ReadOnlyDirectory.fSeekDir` being 64-bit integers,
        rather than 32-bit.

        Note that a file being 64-bit is distinct from a ``TDirectory`` being
        64-bit; see :ref:`uproot.reading.ReadOnlyFile.is_64bit`.
        éè  r>   r.   r#   r#   r$   rC     s    zReadOnlyDirectory.is_64bitc                 C  s   | j jd | j S )z�
        String that uniquely specifies this ``TDirectory`` path, to use as part
        of object and array cache keys.
        ú:)r"   rV   r!   r.   r#   r#   r$   Ú	cache_key!  s    zReadOnlyDirectory.cache_keyT©Ú	recursiveÚcycleÚfilter_nameÚfilter_classnamec                C  s   t | j||||d�ƒS )uU  
        Args:
            recursive (bool): If True, descend into any nested subdirectories.
                If False, only return the names of objects directly accessible
                in this ``TDirectory``.
            cycle (bool): If True, include the cycle numbers in those names.
            filter_name (None, glob string, regex string in ``"/pattern/i"`` syntax, function of str â†’ bool, or iterable of the above): A
                filter to select keys by name.
            filter_classname (None, glob string, regex string in ``"/pattern/i"`` syntax, function of str â†’ bool, or iterable of the above): A
                filter to select keys by C++ (decoded) classname.

        Returns the names of the objects in this ``TDirectory`` as a list of
        strings.

        Note that this does not read any data from the file.
        r#  )rÑ   Úiterkeys©r/   r$  r%  r&  r'  r#   r#   r$   Úkeys)  s    üÿzReadOnlyDirectory.keys©r$  r&  r'  c                C  s   t | j|||d�ƒS )u/  
        Args:
            recursive (bool): If True, descend into any nested subdirectories.
                If False, only return objects directly accessible in this
                ``TDirectory``.
            filter_name (None, glob string, regex string in ``"/pattern/i"`` syntax, function of str â†’ bool, or iterable of the above): A
                filter to select keys by name.
            filter_classname (None, glob string, regex string in ``"/pattern/i"`` syntax, function of str â†’ bool, or iterable of the above): A
                filter to select keys by C++ (decoded) classname.

        Returns objects in this ``TDirectory`` as a list of
        :doc:`uproot.model.Model`.

        Note that this reads all objects that are selected by ``filter_name``
        and ``filter_classname``.
        r+  )rÑ   Ú
itervalues)r/   r$  r&  r'  r#   r#   r$   rÒ   J  s    ýÿzReadOnlyDirectory.valuesc                C  s   t | j||||d�ƒS )u³  
        Args:
            recursive (bool): If True, descend into any nested subdirectories.
                If False, only return (name, object) pairs directly accessible
                in this ``TDirectory``.
            cycle (bool): If True, include the cycle numbers in the names.
            filter_name (None, glob string, regex string in ``"/pattern/i"`` syntax, function of str â†’ bool, or iterable of the above): A
                filter to select keys by name.
            filter_classname (None, glob string, regex string in ``"/pattern/i"`` syntax, function of str â†’ bool, or iterable of the above): A
                filter to select keys by C++ (decoded) classname.

        Returns (name, object) pairs for objects in this ``TDirectory`` as a
        list of 2-tuples of (str, :doc:`uproot.model.Model`).

        Note that this reads all objects that are selected by ``filter_name``
        and ``filter_classname``.
        r#  )rÑ   Ú	iteritemsr)  r#   r#   r$   r   i  s    üÿzReadOnlyDirectory.itemsc                C  s   t | j||||d�ƒS )uƒ  
        Args:
            recursive (bool): If True, descend into any nested subdirectories.
                If False, only return the names and classnames of objects
                directly accessible in this ``TDirectory``.
            cycle (bool): If True, include the cycle numbers in the names.
            filter_name (None, glob string, regex string in ``"/pattern/i"`` syntax, function of str â†’ bool, or iterable of the above): A
                filter to select keys by name.
            filter_classname (None, glob string, regex string in ``"/pattern/i"`` syntax, function of str â†’ bool, or iterable of the above): A
                filter to select keys by C++ (decoded) classname.

        Returns the names and C++ (decoded) classnames of the objects in this
        ``TDirectory`` as a dict of str â†’ str.

        Note that this does not read any data from the file.
        r#  )r   Úiterclassnamesr)  r#   r#   r$   Ú
classnames‹  s    üÿzReadOnlyDirectory.classnamesc                c  sü   t j |¡}t j |¡}tƒ }| jD ]Ò}|tu s:||jƒrp|tu sL||jƒrp|j|d�}||vrf|V  | 	|¡ |r$|jdv r$| 
¡ j||t|d�D ]`}|jdd�› d|› �}	d|	v rÈ|	d|	 d¡… n|	}
|tu sÜ||
ƒr”|	|vrê|	V  | 	|	¡ q”q$dS )u\  
        Args:
            recursive (bool): If True, descend into any nested subdirectories.
                If False, only return the names of objects directly accessible
                in this ``TDirectory``.
            cycle (bool): If True, include the cycle numbers in those names.
            filter_name (None, glob string, regex string in ``"/pattern/i"`` syntax, function of str â†’ bool, or iterable of the above): A
                filter to select keys by name.
            filter_classname (None, glob string, regex string in ``"/pattern/i"`` syntax, function of str â†’ bool, or iterable of the above): A
                filter to select keys by C++ (decoded) classname.

        Returns the names of the objects in this ``TDirectory`` as an iterator
        over strings.

        Note that this does not read any data from the file.
        ©r%  ©r4   r5   r#  Fr  ú;N)r   r   Úregularize_filterÚsetr
  r   r  Ú
fClassNamer¯   ÚaddrÐ   r(  r   )r/   r$  r%  r&  r'  ÚseenrÖ   rU   Úk1Úk2Úk3r#   r#   r$   r(  ¬  s4    
ÿÿ
ü
zReadOnlyDirectory.iterkeysc                c  s&   | j |d||d�D ]\}}|V  qdS )u6  
        Args:
            recursive (bool): If True, descend into any nested subdirectories.
                If False, only return objects directly accessible in this
                ``TDirectory``.
            filter_name (None, glob string, regex string in ``"/pattern/i"`` syntax, function of str â†’ bool, or iterable of the above): A
                filter to select keys by name.
            filter_classname (None, glob string, regex string in ``"/pattern/i"`` syntax, function of str â†’ bool, or iterable of the above): A
                filter to select keys by C++ (decoded) classname.

        Returns objects in this ``TDirectory`` as an iterator over
        :doc:`uproot.model.Model`.

        Note that this reads all objects that are selected by ``filter_name``
        and ``filter_classname``.
        Fr#  N)r-  )r/   r$  r&  r'  r  r²   r#   r#   r$   r,  Þ  s    üzReadOnlyDirectory.itervaluesc                c  s  t j |¡}t j |¡}tƒ }| jD ]ä}|tu s:||jƒrx|tu sL||jƒrx|j|d�}||vrn|| 	¡ fV  | 
|¡ |r$|jdv r$| 	¡ j||t|d�D ]j\}}	|jdd�› d|› �}
d|
v rÔ|
d|
 d¡… n|
}|tu sè||ƒrœ|
|v� rü|
|	fV  | 
|
¡ qœq$dS )uº  
        Args:
            recursive (bool): If True, descend into any nested subdirectories.
                If False, only return (name, object) pairs directly accessible
                in this ``TDirectory``.
            cycle (bool): If True, include the cycle numbers in the names.
            filter_name (None, glob string, regex string in ``"/pattern/i"`` syntax, function of str â†’ bool, or iterable of the above): A
                filter to select keys by name.
            filter_classname (None, glob string, regex string in ``"/pattern/i"`` syntax, function of str â†’ bool, or iterable of the above): A
                filter to select keys by C++ (decoded) classname.

        Returns (name, object) pairs for objects in this ``TDirectory`` as an
        iterator over 2-tuples of (str, :doc:`uproot.model.Model`).

        Note that this reads all objects that are selected by ``filter_name``
        and ``filter_classname``.
        r0  r1  r#  Fr  r2  N)r   r   r3  r4  r
  r   r  r5  r¯   rÐ   r6  r-  r   ©r/   r$  r%  r&  r'  r7  rÖ   rU   r8  r²   r9  r:  r#   r#   r$   r-  ý  s4    
ÿÿ
ü

zReadOnlyDirectory.iteritemsc                c  s
  t j |¡}t j |¡}tƒ }| jD ]à}|tu s:||jƒrv|tu sL||jƒrv|j|d�}||vrl||jfV  | 	|¡ |r$|jdv r$| 
¡ j||t|d�D ]h\}}	|jdd�› d|› �}
d|
v rÒ|
d|
 d¡… n|
}|tu sæ||ƒrš|
|vrø|
|	fV  | 	|
¡ qšq$dS )u“  
        Args:
            recursive (bool): If True, descend into any nested subdirectories.
                If False, only return the names and classnames of objects
                directly accessible in this ``TDirectory``.
            cycle (bool): If True, include the cycle numbers in the names.
            filter_name (None, glob string, regex string in ``"/pattern/i"`` syntax, function of str â†’ bool, or iterable of the above): A
                filter to select keys by name.
            filter_classname (None, glob string, regex string in ``"/pattern/i"`` syntax, function of str â†’ bool, or iterable of the above): A
                filter to select keys by C++ (decoded) classname.

        Returns the names and C++ (decoded) classnames of the objects in this
        ``TDirectory`` as an iterator of 2-tuples of (str, str).

        Note that this does not read any data from the file.
        r0  r1  r#  Fr  r2  N)r   r   r3  r4  r
  r   r  r5  r¯   r6  rÐ   r.  r   r;  r#   r#   r$   r.  0  s4    
ÿÿ
ü
z ReadOnlyDirectory.iterclassnamesc                 C  s   |   ¡ S )zJ
        Supports key-completion in an IPython or Jupyter kernel.
        ©r(  r.   r#   r#   r$   Ú_ipython_key_completions_b  s    z+ReadOnlyDirectory._ipython_key_completions_c                 C  s0   | j d u r*t| jƒtdd„ | jD ƒƒ | _ | j S )Nc                 s  s$   | ]}|j d v rt| ¡ ƒV  qdS )r1  N)r5  r   rÐ   rH   r#   r#   r$   rK   j  s   
þz,ReadOnlyDirectory.__len__.<locals>.<genexpr>)r  r   r
  Úsumr.   r#   r#   r$   Ú__len__h  s
    
þzReadOnlyDirectory.__len__c                 C  s,   z|   |¡ W n ty"   Y dS 0 dS d S )NFT)rÖ   ÚKeyError)r/   Úwherer#   r#   r$   Ú__contains__q  s
    zReadOnlyDirectory.__contains__c                 C  s   |   ¡ S r,   r<  r.   r#   r#   r$   Ú__iter__y  s    zReadOnlyDirectory.__iter__c                 C  s|   t  d|¡}|  }}|d d… D ]N}|dkr t|tƒrD|}|| }q tj|t|ƒd dd„ |jD ƒ| jj	d�‚q ||d fS )Nz[:/]r×   rF   z is not a TDirectoryc                 S  s   g | ]
}|j ‘qS r#   ©r  ©rI   rÖ   r#   r#   r$   r¿   ˆ  rL   z7ReadOnlyDirectory.descent_into_path.<locals>.<listcomp>©Zbecauser*  r    )
rã   Úsplitr   r¡   r   ÚKeyInFileErrorr  r
  rý   r    )r/   rA  r   ÚstepÚlastÚitemr#   r#   r$   Údescent_into_path|  s    


üz#ReadOnlyDirectory.descent_into_pathc                 C  s>   |rd|v sd|v r,|   |¡\}}|| jS |  |¡ ¡ S dS )aÖ  
        Returns the title of the object selected by ``where``.

        The syntax for ``where`` is the same as in square brakets, namely that
        cycle numbers can be specified after semicolons (``;``) and nested
        ``TDirectories`` can be specified with slashes (``/``).

        Unlike the square bracket syntax, this method cannot descend into the
        ``TBranches`` of a ``TTree``.

        Note that this does not read any data from the file.
        r  r!  N)rL  ÚtitlerÖ   )r/   rA  r$  rI  Ú	last_itemr#   r#   r$   Útitle_of�  s    
zReadOnlyDirectory.title_ofFNc                 C  sD   |rd|v sd|v r,|   |¡\}}|| jS |  |¡j||d�S dS )a^  
        Returns the classname of the object selected by ``where``. If
        ``encoded`` with a possible ``version``, return a Python classname;
        otherwise, return a C++ (decoded) classname.

        The syntax for ``where`` is the same as in square brakets, namely that
        cycle numbers can be specified after semicolons (``;``) and nested
        ``TDirectories`` can be specified with slashes (``/``).

        Unlike the square bracket syntax, this method cannot descend into the
        ``TBranches`` of a ``TTree``.

        Note that this does not read any data from the file.
        r  r!  )Úencodedr@   N)rL  r­   rÖ   )r/   rA  rP  r@   r$  rI  rN  r#   r#   r$   Úclassname_of   s    
zReadOnlyDirectory.classname_ofc                 C  sN   |rd|v sd|v r.| j j| j||d�|d�S |  |¡}| j j|j|d�S dS )a£  
        Returns a class object for the ROOT object selected by ``where``. If
        ``version`` is specified, get a :doc:`uproot.model.VersionedModel`;
        otherwise, get a :doc:`uproot.model.DispatchByVersion` or a versionless
        :doc:`uproot.model.Model`.

        The syntax for ``where`` is the same as in square brakets, namely that
        cycle numbers can be specified after semicolons (``;``) and nested
        ``TDirectories`` can be specified with slashes (``/``).

        Unlike the square bracket syntax, this method cannot descend into the
        ``TBranches`` of a ``TTree``.

        Note that this does not read any data from the file.
        r  r!  r£   N)rý   rë   rQ  rÖ   r5  ©r/   rA  r@   r$  rÖ   r#   r#   r$   Úclass_of¶  s    ÿ
zReadOnlyDirectory.class_ofr¢   c                 C  sN   |rd|v sd|v r.| j j| j||d�|d�S |  |¡}| j j|j|d�S dS )a'  
        Returns a ``TStreamerInfo`` (:doc:`uproot.streamers.Model_TStreamerInfo`)
        for the object selected by ``where`` and ``version``.

        The syntax for ``where`` is the same as in square brakets, namely that
        cycle numbers can be specified after semicolons (``;``) and nested
        ``TDirectories`` can be specified with slashes (``/``).

        Unlike the square bracket syntax, this method cannot descend into the
        ``TBranches`` of a ``TTree``.

        Note that this does not read any data from the file.
        r  r!  r£   N)rý   rÔ   rQ  rÖ   r5  rR  r#   r#   r$   Ústreamer_ofÎ  s    ÿ
zReadOnlyDirectory.streamer_ofc           
      C  sN  t j |¡}d|v r,|  |¡\}}| |¡S d|v rˆ| d¡}|d|… ||d d…  }}zt|ƒ}W q’ ty„   |d }}Y q’0 n
|d }}d}| j 	|g ¡D ]V}| j
| }	||	jkrÄ|	  S |du rÚ|du rÚ|	}q¤|du r¤t|jƒt|	jƒk r¤|	}q¤|du�r
|S |du �r0t j|d|  ¡ | jjd�‚nt j|||  ¡ | jjd�‚dS )a#  
        Returns a ``TKey`` (:doc:`uproot.reading.ReadOnlyKey`) for the object
        selected by ``where``.

        The syntax for ``where`` is the same as in square brakets, namely that
        cycle numbers can be specified after semicolons (``;``) and nested
        ``TDirectories`` can be specified with slashes (``/``).

        Unlike the square bracket syntax, this method cannot descend into the
        ``TBranches`` of a ``TTree`` (since they have no ``TKeys``).

        Note that this does not read any data from the file.
        r  r2  Nr   Úany)r%  r*  r    )r   r   rè   rL  rÖ   ÚrindexÚintr   r  rÐ   r
  ÚfCycleÚabsrH  r*  rý   r    )
r/   rA  rI  rN  ÚatrK  r%  rJ  r   rÖ   r#   r#   r$   rÖ   ä  s<    






ÿÿzReadOnlyDirectory.keyc           
      C  sš  d|v sd|v �rˆ|  d¡}|  }}t|ƒD �]T\}}|dkr,t|tƒ�r"d|v rî||vrî| d¡}|d |… ||d d …  }}	|}|| }t|tjjjƒrÂ|d 	|	g||d d …  ¡   S tj
|t|ƒd dd„ |jD ƒ| jjd�‚n2d|v �r||v �r|  |¡ ¡   S |}|| }q,t|tjjjƒ�rN|d 	||d … ¡   S tj
|d 	|d |… ¡d d	d„ |jD ƒ| jjd�‚q,|S |  |¡ ¡ S d S )
Nr  r!  rF   r   z' is not a TDirectory, TTree, or TBranchc                 S  s   g | ]
}|j ‘qS r#   rD  rE  r#   r#   r$   r¿   ,  rL   z1ReadOnlyDirectory.__getitem__.<locals>.<listcomp>rF  c                 S  s   g | ]
}|j ‘qS r#   rD  rE  r#   r#   r$   r¿   =  rL   )rG  Ú	enumerater   r¡   r   r   Z	behaviorsZTBranchZHasBranchesrS   rH  r  r
  rý   r    rÖ   rÐ   )
r/   rA  r   rI  rJ  rÜ   rK  r   ÚheadÚtailr#   r#   r$   Ú__getitem__  sJ    

$ÿû
ÿûzReadOnlyDirectory.__getitem__c                 C  s   | j S )zB
        Raw integer version of the ``TDirectory`` class.
        r>   r.   r#   r#   r$   rZ   F  s    zReadOnlyDirectory.fVersionc                 C  s   | j S )zž
        Raw integer creation date/time.

        :ref:`uproot.reading.ReadOnlyDirectory.created_on` presents this time
        as a Python datetime.
        )r  r.   r#   r#   r$   ÚfDatimeCM  s    zReadOnlyDirectory.fDatimeCc                 C  s   | j S )z«
        Raw integer date/time of last modification.

        :ref:`uproot.reading.ReadOnlyDirectory.modified_on` presents this time
        as a Python datetime.
        )r  r.   r#   r#   r$   ÚfDatimeMW  s    zReadOnlyDirectory.fDatimeMc                 C  s   | j S )z„
        Number of bytes in the collection of ``TKeys`` (header key, number of
        directory keys, and directory keys).
        )r  r.   r#   r#   r$   ÚfNbytesKeysa  s    zReadOnlyDirectory.fNbytesKeysc                 C  s   | j S )z@
        Number of bytes in the header up to its title.
        re   r.   r#   r#   r$   rg   i  s    zReadOnlyDirectory.fNbytesNamec                 C  s   | j S )zA
        File seek position (int) of the ``TDirectory``.
        )r  r.   r#   r#   r$   ÚfSeekDirp  s    zReadOnlyDirectory.fSeekDirc                 C  s   | j S )z^
        File seek position (int) of the parent object (``TDirectory`` or ``TFile``).
        )r  r.   r#   r#   r$   ÚfSeekParentw  s    zReadOnlyDirectory.fSeekParentc                 C  s   | j S )z�
        File seek position (int) to the collection of ``TKeys`` (header key,
        number of directory keys, and directory keys).
        )r  r.   r#   r#   r$   Ú	fSeekKeys~  s    zReadOnlyDirectory.fSeekKeysc                 K  s   dS )z÷
        Called in the :doc:`uproot.reading.ReadOnlyDirectory` constructor before
        reading the ``TDirectory`` header fields.

        This is the first hook called in the
        :doc:`uproot.reading.ReadOnlyDirectory` constructor.
        Nr#   rð   r#   r#   r$   rÿ   †  s    z"ReadOnlyDirectory.hook_before_readc                 K  s   dS )z¨
        Called in the :doc:`uproot.reading.ReadOnlyDirectory` constructor after
        reading the ``TDirectory`` header fields and before interpreting them.
        Nr#   rð   r#   r#   r$   rƒ   �  s    z'ReadOnlyDirectory.hook_before_interpretc                 K  s   dS )zÂ
        Called in the :doc:`uproot.reading.ReadOnlyDirectory` constructor after
        interpreting the ``TDirectory`` header fields and before reading the
        chunk of ``TKeys``.
        Nr#   rð   r#   r#   r$   r  •  s    z'ReadOnlyDirectory.hook_before_read_keysc                 K  s   dS )z­
        Called in the :doc:`uproot.reading.ReadOnlyDirectory` constructor after
        reading the chunk of ``TKeys`` and before interpreting the header ``TKey``.
        Nr#   rð   r#   r#   r$   r  œ  s    z(ReadOnlyDirectory.hook_before_header_keyc                 K  s   dS )zË
        Called in the :doc:`uproot.reading.ReadOnlyDirectory` constructor after
        interpreting the header ``TKey`` and number of keys, and before
        interpeting the object ``TKeys``.
        Nr#   rð   r#   r#   r$   r  ¢  s    z"ReadOnlyDirectory.hook_before_keysc                 K  s   dS )zí
        Called in the :doc:`uproot.reading.ReadOnlyDirectory` constructor after
        interpeting the object ``TKeys``.

        This is the last hook called in the
        :doc:`uproot.reading.ReadOnlyDirectory` constructor.
        Nr#   rð   r#   r#   r$   r  ©  s    z!ReadOnlyDirectory.hook_after_keys)T)FNT)NT)r¢   T)7r1   r2   r3   rp   r0   rŽ   rq   r   r!   r    r"   r‘   r•   r–   r—   r  r  r…   r  rC   r"  r   r*  rÒ   r   r/  r(  r,  r-  r.  r=  r?  rB  rC  rL  rO  rQ  rS  rT  rÖ   r^  rZ   r_  r`  ra  rg   rb  rc  rd  rÿ   rƒ   r  r  r  r  r#   r#   r#   r$   r¡   ô  sÆ   Gj







	
	




ú$û"ú%ú$ú5û"ú6ú2	



4.

	
	




	r¡   z	>ihiIhhiiz	>ihiIhhqqc                   @  sn  e Zd ZdZdDdd„Zdd„ Zedd„ ƒZed	d
„ ƒZedd„ ƒZ	edd„ ƒZ
dEdd„Zdd„ ZdFdd„Zedd„ ƒZedd„ ƒZedd„ ƒZedd„ ƒZedd„ ƒZed d!„ ƒZed"d#„ ƒZd$d%„ Zd&d'„ Zed(d)„ ƒZed*d+„ ƒZed,d-„ ƒZed.d/„ ƒZed0d1„ ƒZed2d3„ ƒZed4d5„ ƒZed6d7„ ƒZed8d9„ ƒZed:d;„ ƒZ ed<d=„ ƒZ!d>d?„ Z"d@dA„ Z#dBdC„ Z$dS )GrÃ   ai  
    Args:
        chunk (:doc:`uproot.source.chunk.Chunk`): Buffer of contiguous data
            from the file :doc:`uproot.source.chunk.Source`.
        cursor (:doc:`uproot.source.cursor.Cursor`): Current position in
            the :doc:`uproot.reading.ReadOnlyFile`.
        context (dict): Auxiliary data used in deserialization.
        file (:doc:`uproot.reading.ReadOnlyFile`): The open file object.
        parent (None or calling object): The previous ``read`` in the
            recursive descent.
        read_strings (bool): If True, interpret the `fClassName`, `fName`, and
            `fTitle` attributes; otherwise, ignore them.

    Represents a ``TKey`` in a ROOT file, which aren't often accessed by users.

    See the `ROOT TKey documentation <https://root.cern.ch/doc/master/classTKey.html>`__
    for a specification of ``TKey`` header fields.
    Fc              	   C  s  |  ¡ | _|| _|| _| j||||||d� |j|t|dd�\| _| _| _	| _
| _| _| _| _| jr”| |t|¡\| _| _| _	| _
| _| _| _| _n| tj¡ |ræ| j||||||d� | ||¡| _| ||¡| _| ||¡| _nd | _d | _d | _| j||||||d� d S )N)r€   r…   r  r"   r  rù   Frõ   )rw   rü   rý   rþ   rƒ   r‡   Ú_key_format_smallÚ_fNbytesr?   Ú_fObjlenÚ_fDatimeÚ_fKeylenÚ_fCycleÚ	_fSeekKeyÚ
_fSeekPdirrC   rÁ   r	  r   Úhook_before_stringsÚstringÚ_fClassNameÚ_fNameÚ_fTitler‰   )r/   r€   r…   r  r"   r  rù   r#   r#   r$   r0   Ë  sr    
ú÷
÷øú	úzReadOnlyKey.__init__c                 C  sX   | j d u s| jd u rd}nd| jdd�› d|  ¡ › �}d|› d| jj› dt| ƒd	›d
�S )NrF   ú Tr0  z: z<ReadOnlyKeyz (seek pos z) at 0xr‹   rŒ   )rp  ro  r¯   r­   Údata_cursorr   r�   )r/   Z	nameclassr#   r#   r$   rŽ   	  s    zReadOnlyKey.__repr__c                 C  s   | j S )zœ
        A :doc:`uproot.source.cursor.Cursor` pointing to the seek point in the
        file where this ``TKey`` starts (before its header fields).
        r  r.   r#   r#   r$   r…   	  s    zReadOnlyKey.cursorc                 C  s   t jj | j| j ¡S )zó
        A :doc:`uproot.source.cursor.Cursor` pointing to the seek point in the
        file where the data begins (the object to be read, after its copy of the
        ``TKey`` and before the object's number of bytes/version header).
        )r   r„   r…   r†   rk  ri  r.   r#   r#   r$   rs  	  s    zReadOnlyKey.data_cursorc                 C  s   | j S )zX
        The :doc:`uproot.reading.ReadOnlyFile` in which this ``TKey`` resides.
        r  r.   r#   r#   r$   r"   '	  s    zReadOnlyKey.filec                 C  s   | j S r  r  r.   r#   r#   r$   r  .	  s    zReadOnlyKey.parentc                 C  s    |r| j › d| j› �S | j S dS )z‹
        The name of the object pointed to by this ``TKey``, with semicolon (``;``)
        and cycle number if ``cycle`` is True.
        r2  N)r  rX  )r/   r%  r#   r#   r$   r¯   6	  s    zReadOnlyKey.namec                 C  s   | j S )zF
        The title of the object pointed to by this ``TKey``.
        )ÚfTitler.   r#   r#   r$   rM  @	  s    zReadOnlyKey.titleNc                 C  s    |rt jj| j|d�S | jS dS )a  
        The classname of the object pointed to by this ``TKey``.

        If ``encoded`` is True, the classname is a Python (encoded) classname
        (optionally with ``version`` number).

        If ``encoded`` is False, the classname is a C++ (decoded) classname.
        r£   N)r   r¦   rç   r5  )r/   rP  r@   r#   r#   r$   r­   F	  s    	zReadOnlyKey.classnamec                 C  sH   t | jtƒr*| jj› |  d¡› d| j› �S d| jj› d|  d¡› �S dS )zâ
        Object path of the object pointed to by this ``TKey``.

        If an object path is not known (e.g. the object does not reside in a
        ``TDirectory``), this returns a message with the raw seek position.
        Fr2  z
(seek pos z)/N)r   rþ   r¡   r!   r¯   rj  rs  r   r.   r#   r#   r$   r!   T	  s    zReadOnlyKey.object_pathc                 C  s   | j j› d| j› �S )zv
        String that uniquely specifies this ``TKey``, to use as part
        of object and array cache keys.
        r!  )rý   rV   rk  r.   r#   r#   r$   r"  a	  s    zReadOnlyKey.cache_keyc                 C  s
   | j dkS )z×
        True if the ``TKey`` is 64-bit ready; False otherwise.

        This refers to seek points like
        :ref:`uproot.reading.ReadOnlyKey.fSeekKey` being 64-bit integers,
        rather than 32-bit.
        r   r>   r.   r#   r#   r$   rC   i	  s    	zReadOnlyKey.is_64bitc                 C  s   | j | jkS )zÛ
        True if the object is compressed; False otherwise.

        Note: compression is determined by comparing ``fObjlen`` and
        ``fNbytes - fKeylen``; if they are the same, the object is uncompressed.
        )Údata_compressed_bytesÚdata_uncompressed_bytesr.   r#   r#   r$   Úis_compressedt	  s    zReadOnlyKey.is_compressedc                 C  s   | j S )z–
        Number of bytes in the uncompressed object (excluding any keys)

        This is equal to :ref:`uproot.reading.ReadOnlyKey.fObjlen`.
        ©rg  r.   r#   r#   r$   rv  ~	  s    z#ReadOnlyKey.data_uncompressed_bytesc                 C  s   | j | j S )zÌ
        Number of bytes in the compressed object (excluding any keys)

        This is equal to :ref:`uproot.reading.ReadOnlyKey.fNbytes`
        minus :ref:`uproot.reading.ReadOnlyKey.fKeylen`.
        )rf  ri  r.   r#   r#   r$   ru  ‡	  s    z!ReadOnlyKey.data_compressed_bytesc                 C  s   t j | j¡S )z£
        Creation date/time as a Python datetime.

        :doc:`uproot.reading.ReadOnlyKey.fDatime` presents this in ROOT's
        raw integer encoding.
        )r   r   r  rh  r.   r#   r#   r$   r  ‘	  s    zReadOnlyKey.created_onc                   sê  ˆ j jdurJˆ j j ˆ j¡}|durJt|jtƒrF|jjrFˆ j jˆ j= n|S ˆ jt	v r`ˆ j }ˆ }nˆ j j
}d}tˆ jtƒrªˆ jdv rªtg ˆ jj¢ˆ j‘R ˆ ji ˆ j ˆ ƒ}�nˆ  ¡ \}}| ¡ }dˆ dœ}t dˆ j¡râ| ||¡S ˆ j  ˆ j¡}z| |||ˆ j ||¡}W n¢ tjj�y¬   | d¡}	|	du �sJt‡ fdd„|	D ƒƒ�rL‚ |	D ]$}
|
jtjjv�rPˆ j  |
j¡ �qP|}ˆ j  ˆ j¡}dˆ dœ}| |||ˆ j ||¡}Y n0 ˆ jt	v�rÊˆ j j
|_ d|_ˆ j jdu�ræ|ˆ j jˆ j< |S )	a–  
        Returns the object pointed to by this ``TKey``, decompressing it if
        necessary.

        If the first attempt to deserialize the object fails with
        :doc:`uproot.deserialization.DeserializationError` and any of the
        models used in that attempt were predefined (not from
        :ref:`uproot.reading.ReadOnlyFile.streamers`), this method will
        try again with the file's own
        :ref:`uproot.reading.ReadOnlyFile.streamers`.

        (Some ROOT files do have classes that don't match the standard
        ``TStreamerInfo``; they may have been produced from private builds of
        ROOT between official releases.)
        Nr1  r#   ©ÚbreadcrumbsZTKeyz(std\s*::\s*)?stringrz  c                 3  s@   | ]8}|j tjjv p6t|tjjƒp6t|jd dƒˆ j	j
kV  qdS )Z	file_uuidN)r­   r   r¦   Úbootstrap_classnamesr   Ú
containersZAsContainerr“   Zclass_streamerrý   rW   )rI   Úbreadcrumb_clsr.   r#   r$   rK   Ö	  s   üÿÿz"ReadOnlyKey.get.<locals>.<genexpr>)rý   r   rÐ   r"  r   r"   r   r•   ro  Úmust_be_attachedr�   rþ   r¡   r   r  rs  rÅ   rw   rã   rä   rn  rë   r   r   ZdeserializationZDeserializationErrorrÊ   r­   r¦   r{  rà   )r/   rU   Zselffiler  r€   r…   Zstart_cursorr  rê   rz  r}  r#   r.   r$   rÐ   ›	  sb    
û	

û
ÿÿ

zReadOnlyKey.getc                 C  s�   t jjjd| j d�}| jj}|| j }| j 	||¡}| j
rXt j || ji | j| j¡}n0| ¡ }t jj	j |j| ||| jd| dœ¡¡}||fS )zº
        Returns an uncompressed :doc:`uproot.source.chunk.Chunk` and
        :doc:`uproot.source.cursor.Cursor` for the object pointed to by this
        ``TKey`` as a 2-tuple.
        r   )Úoriginr#   ry  )r   r„   r…   r†   ri  rs  r   ru  rý   r€   rw  rD   Ú
decompressrv  r�   ZChunkÚwraprÐ   )r/   r…   Z
data_startZ	data_stopr€   Zuncompressed_chunkr#   r#   r$   rÅ   õ	  s.    
û

üþ
z)ReadOnlyKey.get_uncompressed_chunk_cursorc                 C  s   | j S )zR
        The total number of bytes in the compressed object and ``TKey``.
        )rf  r.   r#   r#   r$   ÚfNbytes
  s    zReadOnlyKey.fNbytesc                 C  s   | j S )z<
        Raw integer version of the ``TKey`` class.
        r>   r.   r#   r#   r$   rZ   "
  s    zReadOnlyKey.fVersionc                 C  s   | j S )ze
        The number of bytes in the uncompressed object, not including its
        ``TKey``.
        rx  r.   r#   r#   r$   ÚfObjlen)
  s    zReadOnlyKey.fObjlenc                 C  s   | j S )z¦
        Raw integer date/time when the object was written.

        :doc:`uproot.reading.ReadOnlyKey.created_on` presents this as a Python
        datetime.
        )rh  r.   r#   r#   r$   ÚfDatime1
  s    zReadOnlyKey.fDatimec                 C  s   | j S )zP
        The number of bytes in the ``TKey``, not including the object.
        )ri  r.   r#   r#   r$   ÚfKeylen;
  s    zReadOnlyKey.fKeylenc                 C  s   | j S )z�
        The cycle number of the object, which disambiguates different versions
        of an object with the same name.
        )rj  r.   r#   r#   r$   rX  B
  s    zReadOnlyKey.fCyclec                 C  s   | j S )z}
        File seek position (int) pointing to a second copy of this ``TKey``, just
        before the object itself.
        )rk  r.   r#   r#   r$   ÚfSeekKeyJ
  s    zReadOnlyKey.fSeekKeyc                 C  s   | j S )zf
        File seek position (int) to the ``TDirectory`` in which this object
        resides.
        )rl  r.   r#   r#   r$   Ú	fSeekPdirR
  s    zReadOnlyKey.fSeekPdirc                 C  s   | j S )z©
        The C++ (decoded) classname of the object or None if the
        :doc:`uproot.reading.ReadOnlyKey` was constructed with
        ``read_strings=False``.
        )ro  r.   r#   r#   r$   r5  Z
  s    zReadOnlyKey.fClassNamec                 C  s   | j S )zŽ
        The name of the object or None if the :doc:`uproot.reading.ReadOnlyKey`
        was constructed with ``read_strings=False``.
        )rp  r.   r#   r#   r$   r  c
  s    zReadOnlyKey.fNamec                 C  s   | j S )z�
        The title of the object or None if the :doc:`uproot.reading.ReadOnlyKey`
        was constructed with ``read_strings=False``.
        )rq  r.   r#   r#   r$   rt  k
  s    zReadOnlyKey.fTitlec                 K  s   dS )z×
        Called in the :doc:`uproot.reading.ReadOnlyKey` constructor before
        interpeting anything.

        This is the first hook called in the
        :doc:`uproot.reading.ReadOnlyKey` constructor.
        Nr#   rð   r#   r#   r$   rƒ   s
  s    z!ReadOnlyKey.hook_before_interpretc                 K  s   dS )as  
        Called in the :doc:`uproot.reading.ReadOnlyKey` constructor after
        interpeting the header and before interpreting
        :ref:`uproot.reading.ReadOnlyKey.fClassName`,
        :ref:`uproot.reading.ReadOnlyKey.fName`, and
        :ref:`uproot.reading.ReadOnlyKey.fTitle`.

        Only called if ``read_strings=True`` is passed to the constructor.
        Nr#   rð   r#   r#   r$   rm  |
  s    zReadOnlyKey.hook_before_stringsc                 K  s   dS )z×
        Called in the :doc:`uproot.reading.ReadOnlyKey` constructor after
        interpeting everything.

        This is the last hook called in the
        :doc:`uproot.reading.ReadOnlyKey` constructor.
        Nr#   rð   r#   r#   r$   r‰   ‡
  s    z ReadOnlyKey.hook_after_interpret)F)F)FN)%r1   r2   r3   rp   r0   rŽ   rq   r…   rs  r"   r  r¯   rM  r­   r!   r"  rC   rw  rv  ru  r  rÐ   rÅ   r‚  rZ   rƒ  r„  r…  rX  r†  r‡  r5  r  rt  rƒ   rm  r‰   r#   r#   r#   r$   rÃ   ·  sn   
D











	

	
	Z&



	






	rÃ   )&rp   Ú
__future__r   rã   Ústructró   rW   Úcollections.abcr   r   Úpathlibr   Útypingr   r   Zuproot.behaviors.TBranchZuproot.source.fsspecZuproot._utilr   r%   Úplatformrv   r   r+   r~  r6   rr   ÚStructrˆ   r~   r   r  r  r  r¡   re  rÁ   rÃ   r#   r#   r#   r$   Ú<module>   sr   ù ÷ m&

      


       F

