From d2c8e5e69b906e4a2bbd146e2369ea75af6f1a8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20Alloza=20Gonz=C3=A1lez?= Date: Sun, 24 Oct 2021 21:43:41 +0200 Subject: [PATCH] fix: manage script fails to recognise date from md (#14) --- scripts/manage.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/scripts/manage.py b/scripts/manage.py index 21c9788..de5a435 100644 --- a/scripts/manage.py +++ b/scripts/manage.py @@ -45,11 +45,7 @@ def convert_md_to_yml(date: str): matches = re.finditer(PATTERN, joined) current_year = datetime.datetime.now().year - try: - first_date = parse(date).date() - week_number = first_date.isocalendar()[1] - except ValueError: - week_number = int(date) + week_number = int(date) objs = [] for match in matches: @@ -58,11 +54,13 @@ def convert_md_to_yml(date: str): meal_date = datetime.datetime.strptime( f"{weekday} {week_number} {current_year}", "%A %W %Y" ).date() + lunch = [x.strip("- ") for x in parsed["lunch"].splitlines()] if len(lunch) == 2: lunch1, lunch2 = lunch else: lunch1, lunch2 = lunch[0], None + dinner = parsed["dinner"].strip("- ") obj = dict(date=meal_date, lunch1=lunch1, lunch2=lunch2, dinner=dinner) objs.append(obj)