From 2d6058d4518f09e63613f4918b5e393125307104 Mon Sep 17 00:00:00 2001 From: Govindas Date: Wed, 26 Jan 2022 12:08:19 +0200 Subject: [PATCH] Small code reduction --- gsitegen/generate.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/gsitegen/generate.py b/gsitegen/generate.py index f4367dd..a711dfe 100644 --- a/gsitegen/generate.py +++ b/gsitegen/generate.py @@ -66,11 +66,12 @@ def generateLines(title, lines): def generatePage(title, doc): global pages global titles - global pagescount + if 'pages' not in globals(): pages = [] if 'titles' not in globals(): titles = [] + if 'navbar' in globals(): pages.append(str(E.ul(navbar)) + str(doc)) titles.append(title) @@ -86,7 +87,6 @@ def writePages(homepage): os.mkdir("./website-output") except FileExistsError: pass - print("Output directory already exists, let's clean it!") #TODO only delete files that aren't present in newest site generation #deleting contents of folder without deleting the folder, to increase compatibility with various systems #for root, dirs, files in os.walk('./website-output'): @@ -107,15 +107,13 @@ def writePages(homepage): except FileExistsError: pass - changed = False + changed = True filepath = Path("./website-output" + foldername + "/index.html") if filepath.exists(): with open("./website-output" + foldername + "/index.html", 'r') as newpage: - if newpage.read() != page: - changed = True - else: - changed = True + if newpage.read() == page: + changed = False if changed: with open("./website-output" + foldername + "/index.html", 'w') as newpage: