Skip to content

Commit 50b2ad6

Browse files
Lucio AnderliniLucio Anderlini
authored andcommitted
fix: CompressedHepMCLoader does now load all the files instead of loading repeatedly the last one per batch
1 parent 0f57838 commit 50b2ad6

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

PyLamarr/loaders/CompressedHepMCLoader.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,15 +130,18 @@ def copy_and_maybe_patch_hepmc(self, input_file_data: str):
130130
return "\n".join(dst_lines)
131131

132132
def files_in_archive(self, filename: str, tmp_dir: str):
133+
ret = []
133134
with tarfile.open(filename, mode='r:*') as tar:
134135
for member in tar.getmembers():
135136
if member.isfile() and member.name.endswith("mc2"):
136137
key = os.path.basename(member.name)
137138
file_content = tar.extractfile(member).read().decode('utf-8')
138-
patched_filename = os.path.join(tmp_dir, os.path.basename(filename))
139+
patched_filename = os.path.join(tmp_dir, os.path.basename(key))
139140
with open(patched_filename, 'w') as file_copy:
140141
file_copy.write(self.copy_and_maybe_patch_hepmc(file_content))
141-
yield patched_filename
142+
ret.append(patched_filename)
143+
144+
return ret
142145

143146
def load(self, filename: str):
144147
"""

0 commit comments

Comments
 (0)