do not overwrite existing file(s)

This commit is contained in:
n 2021-03-08 13:55:49 +01:00
parent 0d57449004
commit 753cdc5ce3

View file

@ -51,13 +51,14 @@ for x in myresult:
except OSError:
print ("Creation of the directory %s failed" % path)
print("creating %s/%s.gmi" % (path,quote(filename)))
f = open("%s/%s.gmi" % (path,quote(filename)), "w")
f.write("# %s\n\n" % x[1])
f.write("Publié le %s\n\n" % path)
f.write(html2markdown.convert(x[2]))
f.write("\n\n=> /blog/ Retour au menu du blog")
f.close()
if not os.path.isfile('%s/%s.gmi' % (path,quote(filename))):
print("creating %s/%s.gmi" % (path,quote(filename)))
f = open("%s/%s.gmi" % (path,quote(filename)), "w")
f.write("# %s\n\n" % x[1])
f.write("Publié le %s\n\n" % path)
f.write(html2markdown.convert(x[2]))
f.write("\n\n=> /blog/ Retour au menu du blog")
f.close()
f = open("index.gmi", "a")
f.write("\n=> Retour")