From 775245c3b4547bc5eb2a2d264c47c9ee81dd374a Mon Sep 17 00:00:00 2001 From: Eline Date: Thu, 3 Aug 2023 19:34:30 +0200 Subject: [PATCH] Fixed poster encoding. --- poster.py | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/poster.py b/poster.py index 24085e2..d56404e 100644 --- a/poster.py +++ b/poster.py @@ -5,8 +5,9 @@ from dateutil import relativedelta EVENTS_CSV_PATH = "dogadjaji.csv" CURRENT_TIME = dt.date.today() NEXT_MONTH = CURRENT_TIME + relativedelta.relativedelta(months=1, day=1) -DAYS_OF_WEEK_SR = ("PON", "UTO", "SRE", "CET", "PET", "SUB", "NED") -MONTHS_SR = ("Januar", "Februar", "Mart", "April", "Maj", "Jun", "Jul", "Avgust", "Septembar", "Oktobar", "Novembar", "Decembar") +DAYS_OF_WEEK_SR = ("PON", "UTO", "SRE", "ČET", "PET", "SUB", "NED") +MONTHS_SR = ("Januar", "Februar", "Mart", "April", "Maj", "Jun", "Jul", "Avgust",\ + "Septembar", "Oktobar", "Novembar", "Decembar") def load_events(csv_path:str) -> list[dict]: events = [] @@ -20,11 +21,9 @@ def load_events(csv_path:str) -> list[dict]: event_title = event[3] current_event = {"date":event_date_parsed, "time":event_time, - "title":event_title} - + "title":event_title.strip()} if event_date_parsed >= NEXT_MONTH: events.append(current_event) - return events def render_table(events:list[dict])-> str: @@ -33,18 +32,23 @@ def render_table(events:list[dict])-> str: date = DAYS_OF_WEEK_SR[event["date"].weekday()] day = event["date"].day title = event["title"] - html += f"{date}{day}.{title}\n" + html += f"\t\t\t {date} {day}. {title} \n" return html def render_page(table: str) -> str: - head = "" + head = "\n\t\n\t\n" header = "

DECENTRALA

" subheader = f"

Plan za {MONTHS_SR[NEXT_MONTH.month - 1]}

" link = "" - p1 = "

Radionice počinju u 19h u Društvenom centru Krov u Kraljice Marije 47.

" - p2 = "

Ulaz u zgradu je u prolazu pored Štark prodavnice slatkiša, odmah pored menjačnice. DC Krov je na poslednjem spratu.

" - return f"{head}
{header}{subheader}{table}
{p1}{p2}{link}
" - + p1 = "

Radionice počinju u 19h u Društvenom centru Krov\ +u Kraljice Marije 47.

" + p2 = "

Ulaz u zgradu je u prolazu pored Štark prodavnice slatkiša, odmah\ +pored menjačnice. DC Krov je na poslednjem spratu.

" + return f"\n{head}\n\n\t
\n\t\t{header}\n\t\t{subheader}\ +\n\t\t\n{table}\t\t
\n\t\t{p1}\n\t\t{p2}\n\t\t{link}\n\t
\ +\n\n" + def main(): events = load_events(EVENTS_CSV_PATH) table = render_table(events) @@ -53,6 +57,5 @@ def main(): f.write(page) f.close() - if __name__ == "__main__": main()