From 8c95ca8318e174d8b6989c59305b22a43b730e43 Mon Sep 17 00:00:00 2001 From: Fabian Joswig Date: Thu, 18 Nov 2021 14:39:43 +0000 Subject: [PATCH] feat: input.hadrons._get_files optimized --- pyerrors/input/hadrons.py | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/pyerrors/input/hadrons.py b/pyerrors/input/hadrons.py index 8073871e..2d349845 100644 --- a/pyerrors/input/hadrons.py +++ b/pyerrors/input/hadrons.py @@ -10,16 +10,10 @@ from ..npr import Npr_matrix def _get_files(path, filestem): - ls = [] - for (dirpath, dirnames, filenames) in os.walk(path): - ls.extend(filenames) - break + ls = os.listdir(path) # Clean up file list - files = [] - for line in ls: - if line.startswith(filestem): - files.append(line) + files = list(filter(lambda x: x.startswith(filestem), ls)) if not files: raise Exception('No files starting with', filestem, 'in folder', path)