forked from vitrine/wmaker
Address corner case of stripped output file basename being empty.
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user