fix increment postfix in filenames
This commit is contained in:
parent
5c87f241d1
commit
fe69eff79b
@ -112,13 +112,13 @@ def embed_pictures(page, pict_urls):
|
|||||||
|
|
||||||
|
|
||||||
def write_file(page, title, comment=None):
|
def write_file(page, title, comment=None):
|
||||||
fname = ' '.join(title.replace('/', '_').split()) + '.html'
|
write_inc = lambda i: '_%d' % i if i > 1 else ''
|
||||||
inc = 1
|
inc = 0
|
||||||
while True:
|
while True:
|
||||||
|
inc += 1
|
||||||
|
fname = ' '.join(title.replace('/', '_').split()) + write_inc(inc) + '.html'
|
||||||
if not os.path.exists(fname):
|
if not os.path.exists(fname):
|
||||||
break
|
break
|
||||||
inc += 1
|
|
||||||
fname = title.replace('/', '_') + '_%d.html' % inc
|
|
||||||
|
|
||||||
with open(fname, 'x', newline='\n') as a_file:
|
with open(fname, 'x', newline='\n') as a_file:
|
||||||
print('Saving in file "%s"' % fname)
|
print('Saving in file "%s"' % fname)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user