mirror of
https://github.com/fjosw/pyerrors.git
synced 2025-05-15 03:53:41 +02:00
feat: input.hadrons._get_files optimized
This commit is contained in:
parent
5bd8e8402b
commit
8c95ca8318
1 changed files with 2 additions and 8 deletions
|
@ -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)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue