@@ -50,32 +50,41 @@ def _determine_root_format(filename):
5050 return RootFileFormat .RNTUPLE
5151
5252
53- def get_reader (filename ):
54- """Get an appropriate reader for the passed file.
53+ def get_reader (filenames ):
54+ """Get an appropriate reader for the passed files.
55+ The reader is inferred from the first file if multiple are given.
56+ All files are assumed to be of the same I/O format.
5557
5658 Args:
57- filename (str): The input file
59+ filenames (str or list[str] ): The input file(s)
5860
5961 Returns:
6062 root_io.[Legacy]Reader, sio_io.[Legacy]Reader: an initialized reader that
61- is able to process the input file.
63+ is able to process the input file(s) .
6264
6365 Raises:
64- ValueError: If the file cannot be recognized, or if podio has not been
66+ ValueError: If the files cannot be recognized, or if podio has not been
6567 built with the necessary backend I/O support
68+ IndexError: If filenames is an empty list
6669 """
70+
71+ if isinstance (filenames , str ):
72+ filename = filenames
73+ else :
74+ filename = filenames [0 ]
75+
6776 if filename .endswith (".sio" ):
6877 if _is_frame_sio_file (filename ):
69- return sio_io .Reader (filename )
70- return sio_io .LegacyReader (filename )
78+ return sio_io .Reader (filenames )
79+ return sio_io .LegacyReader (filenames )
7180
7281 if filename .endswith (".root" ):
7382 root_flavor = _determine_root_format (filename )
7483 if root_flavor == RootFileFormat .TTREE :
75- return root_io .Reader (filename )
84+ return root_io .Reader (filenames )
7685 if root_flavor == RootFileFormat .RNTUPLE :
77- return root_io .RNTupleReader (filename )
86+ return root_io .RNTupleReader (filenames )
7887 if root_flavor == RootFileFormat .LEGACY :
79- return root_io .LegacyReader (filename )
88+ return root_io .LegacyReader (filenames )
8089
8190 raise ValueError ("file must end on .root or .sio" )
0 commit comments