Address corner case of stripped output file basename being empty.

This commit is contained in:
2024-12-17 15:06:11 -05:00
parent 0c35859424
commit 8d005d055b
+8 -4
View File
@@ -45,10 +45,14 @@ def main():
settings = parser.parse_args()
for infile in settings.inputs:
if infile.endswith('.in'):
outfile = path.join(settings.outdir, path.basename(infile)[0:-3])
else:
outfile = path.join(settings.outdir, path.basename(infile))
base = path.basename(infile)
if base.endswith('.in'):
base = base[0:-3]
if not base:
raise ValueError(
'Input file "{}" has an empty basefile name after stripping any ".in" suffix'
.format(infile))
outfile = path.join(settings.outdir, base)
with open(infile, 'r', encoding='utf-8') as reader:
lines = reader.readlines()
with open(outfile, 'w', encoding='utf-8') as writer: