fix for the case that there are multiple dotsin file names

This commit is contained in:
jkuhl-uni 2023-02-07 13:52:33 +01:00
parent 839f57444d
commit ea1c89cad1

View file

@ -1032,6 +1032,10 @@ def read_ms5_xsf(path, prefix, qc, corr, sep="r", **kwargs):
found = [] found = []
files = [] files = []
names = [] names = []
if "names" in kwargs:
names = kwargs.get("names")
for (dirpath, dirnames, filenames) in os.walk(path + "/"): for (dirpath, dirnames, filenames) in os.walk(path + "/"):
found.extend(filenames) found.extend(filenames)
break break
@ -1039,16 +1043,17 @@ def read_ms5_xsf(path, prefix, qc, corr, sep="r", **kwargs):
for f in found: for f in found:
if fnmatch.fnmatch(f, prefix + "*.ms5_xsf_" + qc + ".dat"): if fnmatch.fnmatch(f, prefix + "*.ms5_xsf_" + qc + ".dat"):
files.append(f) files.append(f)
if "names" not in kwargs:
if not sep == "": if not sep == "":
names.append(prefix + "|r" + f.split(".")[0].split(sep)[1]) se = f.split(".")[0]
for s in f.split(".")[1:-1]:
se += "." + s
names.append(se.split(sep)[0] + "|r" + se.split(sep)[1])
else: else:
names.append(prefix) names.append(prefix)
files = sorted(files)
if "names" in kwargs:
names = kwargs.get("names")
else:
names = sorted(names) names = sorted(names)
files = sorted(files)
cnfgs = [] cnfgs = []
realsamples = [] realsamples = []