fix events path

This commit is contained in:
Hugo 2023-08-07 17:05:30 +02:00
parent 263d313f76
commit af65cde58f

51
prep.py
View File

@ -7,7 +7,7 @@ days = [
"Ponedeljak", "Ponedeljak",
"Utorak", "Utorak",
"Sreda", "Sreda",
"Cetvrtak", "Četvrtak",
"Petak", "Petak",
"Subota", "Subota",
"Nedelja", "Nedelja",
@ -70,9 +70,7 @@ events = load_events()
events = sort_events(events) events = sort_events(events)
write_events(events) write_events(events)
start = "<table>\n<tr>\n<th>Datum</th>\n<th>Vreme</th>\n<th>Mesto</th>\n<th>Tema</th>\n</tr>\n" events = []
end="\n</table>"
future_events = []
for event in events: for event in events:
date, time, location, title = event.split(", ") date, time, location, title = event.split(", ")
@ -90,41 +88,14 @@ for event in events:
else: else:
future_event.append("<td> "+location.strip()+" </td>") future_event.append("<td> "+location.strip()+" </td>")
future_event.append("<td> "+title+" </td>") future_event.append("<td> "+title+" </td>")
future_events.append("<tr>\n"+"\n".join(future_event)+"\n</tr>") events.append("<tr>\n"+"\n".join(future_event)+"\n</tr>")
events = [] with open("pages/sr/events.html","wt") as file:
events.append(start) file.writelines(["<h1>Događaji</h1>\n", "<table>\n", "<tr><th>Datum</th><th>Vreme</th><th>Mesto</th><th>Tema</th></tr>\n"])
file.writelines(events)
file.writelines(["</table>"])
for event in future_events: #with open("pages/en/events.html","wt") as file:
events.append(event) # file.writelines(["<h1>Events</h1>", "<table>", "<tr>\n<th>Date</th>\n<th>Time</th>\n<th>Place</th>\n<th>Theme</th>\n</tr>"])
# file.writelines(events)
events.append(end) # file.writelines(["</table>"])
with open("pages/events.html","rt") as file:
html = file.readlines()
new_html = []
i=0
while i<len(html):
original_line = html[i]
line = original_line.strip()
if line == '<!-- dogadjaji start -->':
new_html.append(original_line)
for event in events:
new_html.append(event+"\n")
new_html.append(" <!-- dogadjaji end -->\n")
while line!='<!-- dogadjaji end -->':
i+=1
line=html[i].strip()
i+=1
while i<len(html):
new_html.append(html[i])
i+=1
else:
new_html.append(original_line)
i+=1
with open("pages/events.html","wt") as file:
file.writelines(new_html)