Use 2 spaces instead of tab

This commit is contained in:
Govindas 2022-01-21 13:09:43 +02:00
parent 09acb1a9fc
commit acf1a5a097

View File

@ -6,48 +6,47 @@ from shutil import rmtree
homepage = "Home"
try:
os.mkdir("./website-output")
os.mkdir("./website-output")
except FileExistsError:
print("Output directory already exists, let's clean it!")
print("Output directory already exists, let's clean it!")
#deleting contents of folder without deleting the folder, to increase compatibility with various systems
for root, dirs, files in os.walk('./website-output'):
for f in files:
os.unlink(os.path.join(root, f))
for d in dirs:
rmtree(os.path.join(root, d))
#deleting contents of folder without deleting the folder, to increase compatibility with various systems
for root, dirs, files in os.walk('./website-output'):
for f in files:
os.unlink(os.path.join(root, f))
for d in dirs:
rmtree(os.path.join(root, d))
#generate navigation bar
navbarfound = False
if os.path.exists("./navbar"):
with open("./navbar", 'r') as navbarfile:
navbarfound = True
navbar = ""
for line in navbarfile.readlines():
split = line.strip().split(";", 1)
navbar = navbar + "<li><a href='" + split[1] + "'>" + split[0] + "</a></li>"
print(navbar)
with open("./navbar", 'r') as navbarfile:
navbarfound = True
navbar = ""
for line in navbarfile.readlines():
split = line.strip().split(";", 1)
navbar = navbar + "<li><a href='" + split[1] + "'>" + split[0] + "</a></li>"
else:
print("No 'navbar' file found, there will be no navigation bar.")
print("No 'navbar' file found, there will be no navigation bar.")
#generate pages
for file in os.listdir("./"):
if file.endswith(".page"):
with open(file, 'r') as page:
pagetitle = os.path.basename(file).replace(".page", "")
doc = Document(pagetitle, lang="en")
for line in page.readlines():
doc.p(line.strip())
if file.endswith(".page"):
with open(file, 'r') as page:
pagetitle = os.path.basename(file).replace(".page", "")
doc = Document(pagetitle, lang="en")
for line in page.readlines():
doc.p(line.strip())
#creates ./website-output/pagetitle/index.html file if it is not homepage
if pagetitle == homepage:
foldername = ""
else:
foldername = "/" + pagetitle.replace(" ", "-").lower()
os.mkdir("./website-output" + foldername)
#creates ./website-output/pagetitle/index.html file if it is not homepage
if pagetitle == homepage:
foldername = ""
else:
foldername = "/" + pagetitle.replace(" ", "-").lower()
os.mkdir("./website-output" + foldername)
with open("./website-output" + foldername + "/index.html", 'w') as newpage:
if navbarfound:
newpage.write("<ul>" + navbar + "</ul>" + str(doc))
else:
newpage.write(str(doc))
with open("./website-output" + foldername + "/index.html", 'w') as newpage:
if navbarfound:
newpage.write("<ul>" + navbar + "</ul>" + str(doc))
else:
newpage.write(str(doc))