Coverage for src/evutils/io/__init__.py: 100%

4 statements  

« prev     ^ index     » next       coverage.py v7.15.1, created at 2026-07-18 05:24 +0000

1"""Reading and writing events in various file formats. 

2 

3Format-specific readers and writers (``bin``, ``csv``, ``dat``, ``hdf5``, 

4``npz``, ``raw``, ``txt``) built on a shared ``EventReader`` / ``EventWriter`` 

5interface, plus ``EventReader_Any`` / ``EventWriter_Any`` which pick the 

6backend from the file extension. Backends that need optional dependencies 

7degrade gracefully and only raise on use. 

8 

9Compression is transparent: a path ending in ``.gz`` / ``.zst`` / ``.xz`` / 

10``.bz2`` (e.g. ``foo.raw.zst``) is auto-opened through the matching 

11(de)compressing stream on both read and write -- the *inner* extension selects 

12the event format. You may also hand :class:`EventReader` an already-open 

13compressed file object (``gzip.GzipFile``, ``lzma.LZMAFile``, 

14``compression.zstd.ZstdFile``, ...). Writing to a bare stream (as opposed to a 

15path) still requires an explicit ``file_encoder``. ``.zst`` needs Python 3.14+ 

16(stdlib ``compression.zstd``) or the ``zstandard`` / ``pyzstd`` package. 

17""" 

18 

19from ._event_reader import EventReader 

20from ._event_writer import EventWriter 

21from .stream import EventStreamer 

22 

23__all__ = [ 

24 "EventReader", 

25 "EventWriter", 

26 "EventStreamer", 

27]