feat: input.hadrons._get_files optimized

This commit is contained in:
Fabian Joswig 2021-11-18 14:39:43 +00:00
parent 5bd8e8402b
commit 8c95ca8318

View file

@ -10,16 +10,10 @@ from ..npr import Npr_matrix
def _get_files(path, filestem): def _get_files(path, filestem):
ls = [] ls = os.listdir(path)
for (dirpath, dirnames, filenames) in os.walk(path):
ls.extend(filenames)
break
# Clean up file list # Clean up file list
files = [] files = list(filter(lambda x: x.startswith(filestem), ls))
for line in ls:
if line.startswith(filestem):
files.append(line)
if not files: if not files:
raise Exception('No files starting with', filestem, 'in folder', path) raise Exception('No files starting with', filestem, 'in folder', path)