Progress on making code cleaner

This commit is contained in:
Govindas 2022-01-22 11:54:31 +02:00
parent c28b3167a1
commit 0673f6a790

View File

@ -18,17 +18,17 @@ except FileExistsError:
rmtree(os.path.join(root, d))
#generate navigation bar
navbarfound = False
def generateNavigationBar(lines):
global navbar
navbar = E
for line in lines:
split = line.strip().split(";", 1)
navbar.li(HTML("<a href='" + split[1] + "'>" + split[0]))
if os.path.exists("./navbar"):
with open("./navbar", 'r') as navbarfile:
navbarfound = True
navbar = E
for line in navbarfile.readlines():
split = line.strip().split(";", 1)
navbar = navbar.li(HTML("<a href='" + split[1] + "'>" + split[0]))
#checking false instead of else to be more sure
if navbarfound == False:
generateNavigationBar(navbarfile.readlines())
else:
print("No 'navbar' file found, there will be no navigation bar.")
#generate pages
@ -41,13 +41,13 @@ for file in os.listdir("./"):
doc.p(line.strip())
#creates ./website-output/pagetitle/index.html file if it is not homepage
foldername = ""
if pagetitle =! homepage:
foldername = ""
if pagetitle != homepage:
foldername = "/" + pagetitle.replace(" ", "-").lower()
os.mkdir("./website-output" + foldername)
with open("./website-output" + foldername + "/index.html", 'w') as newpage:
if navbarfound:
if 'navbar' in globals():
newpage.write(str(E.ul(navbar)))
else:
newpage.write(str(doc))