Skip to content
Snippets Groups Projects
Commit c17544f0 authored by Florian Obersteiner's avatar Florian Obersteiner
Browse files

isValidFileName revised and added as a warning

parent 4ebb5d84
Branches
Tags
1 merge request!6code refactor
This commit is part of merge request !6. Comments created here will be created in the context of that merge request.
......@@ -710,10 +710,10 @@ class Dataset:
def isAsciiAlpha(x):
return re.match("[a-zA-Z0-9-_.]", x)
allAsciiAlpha = all([isAsciiAlpha(x) for x in name])
allAsciiAlpha = all(isAsciiAlpha(x) for x in name)
lessThan128Characters = len(name) < 128
return allAsciiAlpha and lessThan128Characters
return allAsciiAlpha and lessThan128Characters and name.endswith('.ict')
def writeHeader(self, f=sys.stdout, delimiter=DEFAULT_FIELD_DELIM):
"""Write header
......@@ -914,7 +914,8 @@ class Dataset:
else:
self.inputFhandle = f
# TODO should we add a filename characters check, as we have it for the variable names?
if not self.isValidFileName(pathlib.Path(f).name):
warnings.warn(f"{pathlib.Path(f).name} is not a valid ICARTT filename")
self.readHeader(splitChar)
if loadData:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment