Small code reduction
This commit is contained in:
parent
08f12551c5
commit
2d6058d451
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user