From 01230ea17869155c31a9c2fa3b8eff69ff97f405 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Ke=C3=9Fler?= Date: Thu, 16 Sep 2021 20:07:18 +0200 Subject: [PATCH] move get week method into utils file --- scripts/config.py | 6 ------ scripts/lectures.py | 3 ++- scripts/utils.py | 6 ++++++ 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/scripts/config.py b/scripts/config.py index d0e3019..15a07d0 100644 --- a/scripts/config.py +++ b/scripts/config.py @@ -1,11 +1,5 @@ -from datetime import datetime from pathlib import Path - -def get_week(d=datetime.today()): - return (int(d.strftime("%W")) + 52 - 5) % 52 - - # default is 'primary', if you are using a separate calendar for your course schedule, # your calendarId (which you can find by going to your Google Calendar settings, selecting # the relevant calendar and scrolling down to Calendar ID) probably looks like diff --git a/scripts/lectures.py b/scripts/lectures.py index 03cc664..a5c02cf 100755 --- a/scripts/lectures.py +++ b/scripts/lectures.py @@ -5,7 +5,8 @@ import re import subprocess from datetime import datetime -from config import get_week, DATE_FORMAT, LOCALE, DEFAULT_MASTER_FILE_NAME, DEFAULT_NEW_LECTURE_HEADER +from config import DATE_FORMAT, LOCALE, DEFAULT_MASTER_FILE_NAME, DEFAULT_NEW_LECTURE_HEADER +from utils import get_week # TODO locale.setlocale(locale.LC_TIME, LOCALE) diff --git a/scripts/utils.py b/scripts/utils.py index 428a227..52452bd 100644 --- a/scripts/utils.py +++ b/scripts/utils.py @@ -1,3 +1,5 @@ +from datetime import datetime + from config import MAX_LEN @@ -15,3 +17,7 @@ def generate_short_title(title): short_title = title[:MAX_LEN - len(' ... ')] + ' ... ' short_title = short_title.replace('$', '') return short_title + + +def get_week(d=datetime.today()): + return (int(d.strftime("%W")) + 52 - 5) % 52 \ No newline at end of file