diff --git a/include/aare/CtbRawFile.hpp b/include/aare/CtbRawFile.hpp index ebcfa46..f1c992e 100644 --- a/include/aare/CtbRawFile.hpp +++ b/include/aare/CtbRawFile.hpp @@ -28,6 +28,7 @@ class CtbRawFile { size_t image_size_in_bytes() const; size_t frames_in_file() const; + size_t total_frames() const; RawMasterFile master() const; diff --git a/python/src/bind_RawFile.hpp b/python/src/bind_RawFile.hpp index c31a8c3..85ef155 100644 --- a/python/src/bind_RawFile.hpp +++ b/python/src/bind_RawFile.hpp @@ -280,6 +280,7 @@ void define_raw_file_io_bindings(py::module &m) { .def("tell", &RawFile::tell, R"( Return the current frame number.)") .def_property_readonly("total_frames", &RawFile::total_frames) + .def("__len__", &RawFile::total_frames) .def("rows", static_cast(&RawFile::rows)) .def( "rows", diff --git a/python/src/ctb_raw_file.hpp b/python/src/ctb_raw_file.hpp index 6deff4d..5570254 100644 --- a/python/src/ctb_raw_file.hpp +++ b/python/src/ctb_raw_file.hpp @@ -226,5 +226,7 @@ void define_ctb_raw_file_io_bindings(py::module &m) { .def_property_readonly("image_size_in_bytes", &CtbRawFile::image_size_in_bytes) - .def_property_readonly("frames_in_file", &CtbRawFile::frames_in_file); + .def_property_readonly("frames_in_file", &CtbRawFile::frames_in_file) + .def_property_readonly("total_frames", &CtbRawFile::total_frames) + .def("__len__", &CtbRawFile::total_frames); } diff --git a/python/src/file.hpp b/python/src/file.hpp index 3be4ae2..b602673 100644 --- a/python/src/file.hpp +++ b/python/src/file.hpp @@ -60,6 +60,7 @@ void define_file_io_bindings(py::module &m) { .def("seek", &File::seek) .def("tell", &File::tell) .def_property_readonly("total_frames", &File::total_frames) + .def("__len__", &File::total_frames) .def_property_readonly("rows", &File::rows) .def_property_readonly("cols", &File::cols) .def_property_readonly("bitdepth", &File::bitdepth) diff --git a/python/src/jungfrau_data_file.hpp b/python/src/jungfrau_data_file.hpp index 9b0f188..44ecd90 100644 --- a/python/src/jungfrau_data_file.hpp +++ b/python/src/jungfrau_data_file.hpp @@ -72,6 +72,7 @@ void define_jungfrau_data_file_io_bindings(py::module &m) { .def_property_readonly("bitdepth", &JungfrauDataFile::bitdepth) .def_property_readonly("current_file", &JungfrauDataFile::current_file) .def_property_readonly("total_frames", &JungfrauDataFile::total_frames) + .def("__len__", &JungfrauDataFile::total_frames) .def_property_readonly("n_files", &JungfrauDataFile::n_files) .def("read_frame", &read_dat_frame, R"( diff --git a/src/CtbRawFile.cpp b/src/CtbRawFile.cpp index f22b2f3..260ab66 100644 --- a/src/CtbRawFile.cpp +++ b/src/CtbRawFile.cpp @@ -57,6 +57,8 @@ size_t CtbRawFile::image_size_in_bytes() const { size_t CtbRawFile::frames_in_file() const { return m_master.frames_in_file(); } +size_t CtbRawFile::total_frames() const { return m_master.frames_in_file(); } + RawMasterFile CtbRawFile::master() const { return m_master; } void CtbRawFile::find_subfiles() {