From efd42af35aa61c8dd819c479ea21f80bced0fd7a Mon Sep 17 00:00:00 2001 From: timo Date: Mon, 6 Nov 2023 11:53:28 +0100 Subject: [PATCH 1/9] Add script to generate Freies Hacken Events --- tools/generate_freieshacken_events.py | 45 +++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 tools/generate_freieshacken_events.py diff --git a/tools/generate_freieshacken_events.py b/tools/generate_freieshacken_events.py new file mode 100644 index 0000000..884ae05 --- /dev/null +++ b/tools/generate_freieshacken_events.py @@ -0,0 +1,45 @@ +import os +import datetime + + +# Function to generate the markdown content for a specific date +def generate_markdown_file(year, month, day): + markdown_content = f"""--- +layout: event +title: "Freies Hacken" +event_date: {year}-{month:02d}-{day:02d} +--- +**Wann: 19:30 Uhr**\\ +**Wo: Netz39 e.V.** +Jeden Mittwoch treffen wir uns zum Basteln, Reparieren, Kochen und Ideen austauschen. Gäste sind gerne willkommen + +Bitte beachtet, dass jede dritte Woche unser Stammtisch ist, wo wir über vereinsinterne Sachen reden und erst anschließend zum gemütlichen Abend übergehen. +""" + + folder_path = "_events" + filename = f"{year}-{month:02d}-{day:02d}_n39_freies_hacken.md" + file_path = os.path.join(folder_path, filename) + + with open(file_path, 'w', encoding='utf-8') as file: + file.write(markdown_content) + + print(f"Markdown file '{filename}' generated successfully in the _events folder!") + + +# Input year +input_year = int(input("Enter the year: ")) + +# Calculate Wednesdays in weeks divisible by three +for month in range(1, 13): + for day in range(1, 32): + try: + # Generate a date object + current_date = datetime.date(input_year, month, day) + + # Check if the date is a Wednesday + if current_date.weekday() == 2: + generate_markdown_file(input_year, month, day) + + except ValueError: + # If the day is out of range for the month, skip to the next month + pass From 61f0020244c94558cc28fb84a2709792ce948478 Mon Sep 17 00:00:00 2001 From: timo Date: Thu, 9 Nov 2023 12:02:18 +0100 Subject: [PATCH 2/9] :bulb: Update comment --- tools/generate_freieshacken_events.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/generate_freieshacken_events.py b/tools/generate_freieshacken_events.py index 884ae05..1cdeced 100644 --- a/tools/generate_freieshacken_events.py +++ b/tools/generate_freieshacken_events.py @@ -29,7 +29,7 @@ def generate_markdown_file(year, month, day): # Input year input_year = int(input("Enter the year: ")) -# Calculate Wednesdays in weeks divisible by three +# Calculate Wednesdays for month in range(1, 13): for day in range(1, 32): try: From 9d71edc283c81a9de2d73bebd6984965f8c875a8 Mon Sep 17 00:00:00 2001 From: timo Date: Thu, 9 Nov 2023 12:41:00 +0100 Subject: [PATCH 3/9] :art: Add Variables --- tools/generate_freieshacken_events.py | 29 +++++++++++++++++---------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/tools/generate_freieshacken_events.py b/tools/generate_freieshacken_events.py index 1cdeced..cdb313c 100644 --- a/tools/generate_freieshacken_events.py +++ b/tools/generate_freieshacken_events.py @@ -1,29 +1,36 @@ import os import datetime - -# Function to generate the markdown content for a specific date -def generate_markdown_file(year, month, day): - markdown_content = f"""--- -layout: event -title: "Freies Hacken" -event_date: {year}-{month:02d}-{day:02d} ---- +layout = "event" +title = "Freies Hacken" +event_description = f""" **Wann: 19:30 Uhr**\\ **Wo: Netz39 e.V.** + Jeden Mittwoch treffen wir uns zum Basteln, Reparieren, Kochen und Ideen austauschen. Gäste sind gerne willkommen Bitte beachtet, dass jede dritte Woche unser Stammtisch ist, wo wir über vereinsinterne Sachen reden und erst anschließend zum gemütlichen Abend übergehen. +""" +folder_path = "_events" +filename_prefix = "n39_freies_hacken" + +# Function to generate the markdown content for a specific date +def generate_markdown_file(year, month, day): + markdown_content = f"""--- +layout: {layout} +title: {title} +event_date: {year}-{month:02d}-{day:02d} +--- +{event_description} """ - folder_path = "_events" - filename = f"{year}-{month:02d}-{day:02d}_n39_freies_hacken.md" + filename = f"{year}-{month:02d}-{day:02d}_{filename_prefix}.md" file_path = os.path.join(folder_path, filename) with open(file_path, 'w', encoding='utf-8') as file: file.write(markdown_content) - print(f"Markdown file '{filename}' generated successfully in the _events folder!") + print(f"Markdown file '{filename}' generated successfully in the {folder_path} folder!") # Input year From 07dc6482371ddc400826241b4a2463b87986dc4e Mon Sep 17 00:00:00 2001 From: timo Date: Thu, 9 Nov 2023 13:01:20 +0100 Subject: [PATCH 4/9] :art: Save new Events to subfolder --- tools/generate_freieshacken_events.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tools/generate_freieshacken_events.py b/tools/generate_freieshacken_events.py index cdb313c..3bae5ac 100644 --- a/tools/generate_freieshacken_events.py +++ b/tools/generate_freieshacken_events.py @@ -11,7 +11,7 @@ Bitte beachtet, dass jede dritte Woche unser Stammtisch ist, wo wir über vereinsinterne Sachen reden und erst anschließend zum gemütlichen Abend übergehen. """ -folder_path = "_events" +folder_name = "_events" filename_prefix = "n39_freies_hacken" # Function to generate the markdown content for a specific date @@ -24,13 +24,17 @@ def generate_markdown_file(year, month, day): {event_description} """ + folder_path = f"../{folder_name}/{year}/" filename = f"{year}-{month:02d}-{day:02d}_{filename_prefix}.md" file_path = os.path.join(folder_path, filename) + if not os.path.exists(folder_path): + os.makedirs(folder_path) + with open(file_path, 'w', encoding='utf-8') as file: file.write(markdown_content) - print(f"Markdown file '{filename}' generated successfully in the {folder_path} folder!") + print(f"Markdown file '{filename}' generated successfully in the '{folder_path}' folder!") # Input year From 145a61e1aaced816cfc74b19d0713c265787018e Mon Sep 17 00:00:00 2001 From: timo Date: Thu, 9 Nov 2023 13:23:10 +0100 Subject: [PATCH 5/9] :art: Add CLI Parameter --- tools/generate_freieshacken_events.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tools/generate_freieshacken_events.py b/tools/generate_freieshacken_events.py index 3bae5ac..668f0de 100644 --- a/tools/generate_freieshacken_events.py +++ b/tools/generate_freieshacken_events.py @@ -1,5 +1,6 @@ import os import datetime +import sys layout = "event" title = "Freies Hacken" @@ -37,19 +38,23 @@ def generate_markdown_file(year, month, day): print(f"Markdown file '{filename}' generated successfully in the '{folder_path}' folder!") +if len(sys.argv) < 2: + print(f"Usage: python3 {sys.argv[0]} ") + sys.exit() + # Input year -input_year = int(input("Enter the year: ")) +year = int(sys.argv[1]) # Calculate Wednesdays for month in range(1, 13): for day in range(1, 32): try: # Generate a date object - current_date = datetime.date(input_year, month, day) + current_date = datetime.date(year, month, day) # Check if the date is a Wednesday if current_date.weekday() == 2: - generate_markdown_file(input_year, month, day) + generate_markdown_file(year, month, day) except ValueError: # If the day is out of range for the month, skip to the next month From bf7174c75fdc19f5e636d51003ac951df437b45e Mon Sep 17 00:00:00 2001 From: timo Date: Thu, 9 Nov 2023 13:24:06 +0100 Subject: [PATCH 6/9] :memo: Update Readme --- tools/README.md | 62 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/tools/README.md b/tools/README.md index 51c5a78..383460d 100644 --- a/tools/README.md +++ b/tools/README.md @@ -28,3 +28,65 @@ Markdown file '2024-11-06_n39_stammtisch.md' generated successfully in the _even Markdown file '2024-11-27_n39_stammtisch.md' generated successfully in the _events folder! Markdown file '2024-12-18_n39_stammtisch.md' generated successfully in the _events folder! ``` + +## Netz 39 Freies-Hacken Events erzeugen + +```bash +cd tools +python3 generate_freieshacken_events.py +``` +Output: + +```bash +Markdown file '2024-01-03_n39_freies_hacken.md' generated successfully in the '../_events/2024/' folder! +Markdown file '2024-01-10_n39_freies_hacken.md' generated successfully in the '../_events/2024/' folder! +Markdown file '2024-01-17_n39_freies_hacken.md' generated successfully in the '../_events/2024/' folder! +Markdown file '2024-01-24_n39_freies_hacken.md' generated successfully in the '../_events/2024/' folder! +Markdown file '2024-01-31_n39_freies_hacken.md' generated successfully in the '../_events/2024/' folder! +Markdown file '2024-02-07_n39_freies_hacken.md' generated successfully in the '../_events/2024/' folder! +Markdown file '2024-02-14_n39_freies_hacken.md' generated successfully in the '../_events/2024/' folder! +Markdown file '2024-02-21_n39_freies_hacken.md' generated successfully in the '../_events/2024/' folder! +Markdown file '2024-02-28_n39_freies_hacken.md' generated successfully in the '../_events/2024/' folder! +Markdown file '2024-03-06_n39_freies_hacken.md' generated successfully in the '../_events/2024/' folder! +Markdown file '2024-03-13_n39_freies_hacken.md' generated successfully in the '../_events/2024/' folder! +Markdown file '2024-03-20_n39_freies_hacken.md' generated successfully in the '../_events/2024/' folder! +Markdown file '2024-03-27_n39_freies_hacken.md' generated successfully in the '../_events/2024/' folder! +Markdown file '2024-04-03_n39_freies_hacken.md' generated successfully in the '../_events/2024/' folder! +Markdown file '2024-04-10_n39_freies_hacken.md' generated successfully in the '../_events/2024/' folder! +Markdown file '2024-04-17_n39_freies_hacken.md' generated successfully in the '../_events/2024/' folder! +Markdown file '2024-04-24_n39_freies_hacken.md' generated successfully in the '../_events/2024/' folder! +Markdown file '2024-05-01_n39_freies_hacken.md' generated successfully in the '../_events/2024/' folder! +Markdown file '2024-05-08_n39_freies_hacken.md' generated successfully in the '../_events/2024/' folder! +Markdown file '2024-05-15_n39_freies_hacken.md' generated successfully in the '../_events/2024/' folder! +Markdown file '2024-05-22_n39_freies_hacken.md' generated successfully in the '../_events/2024/' folder! +Markdown file '2024-05-29_n39_freies_hacken.md' generated successfully in the '../_events/2024/' folder! +Markdown file '2024-06-05_n39_freies_hacken.md' generated successfully in the '../_events/2024/' folder! +Markdown file '2024-06-12_n39_freies_hacken.md' generated successfully in the '../_events/2024/' folder! +Markdown file '2024-06-19_n39_freies_hacken.md' generated successfully in the '../_events/2024/' folder! +Markdown file '2024-06-26_n39_freies_hacken.md' generated successfully in the '../_events/2024/' folder! +Markdown file '2024-07-03_n39_freies_hacken.md' generated successfully in the '../_events/2024/' folder! +Markdown file '2024-07-10_n39_freies_hacken.md' generated successfully in the '../_events/2024/' folder! +Markdown file '2024-07-17_n39_freies_hacken.md' generated successfully in the '../_events/2024/' folder! +Markdown file '2024-07-24_n39_freies_hacken.md' generated successfully in the '../_events/2024/' folder! +Markdown file '2024-07-31_n39_freies_hacken.md' generated successfully in the '../_events/2024/' folder! +Markdown file '2024-08-07_n39_freies_hacken.md' generated successfully in the '../_events/2024/' folder! +Markdown file '2024-08-14_n39_freies_hacken.md' generated successfully in the '../_events/2024/' folder! +Markdown file '2024-08-21_n39_freies_hacken.md' generated successfully in the '../_events/2024/' folder! +Markdown file '2024-08-28_n39_freies_hacken.md' generated successfully in the '../_events/2024/' folder! +Markdown file '2024-09-04_n39_freies_hacken.md' generated successfully in the '../_events/2024/' folder! +Markdown file '2024-09-11_n39_freies_hacken.md' generated successfully in the '../_events/2024/' folder! +Markdown file '2024-09-18_n39_freies_hacken.md' generated successfully in the '../_events/2024/' folder! +Markdown file '2024-09-25_n39_freies_hacken.md' generated successfully in the '../_events/2024/' folder! +Markdown file '2024-10-02_n39_freies_hacken.md' generated successfully in the '../_events/2024/' folder! +Markdown file '2024-10-09_n39_freies_hacken.md' generated successfully in the '../_events/2024/' folder! +Markdown file '2024-10-23_n39_freies_hacken.md' generated successfully in the '../_events/2024/' folder! +Markdown file '2024-10-30_n39_freies_hacken.md' generated successfully in the '../_events/2024/' folder! +Markdown file '2024-11-06_n39_freies_hacken.md' generated successfully in the '../_events/2024/' folder! +Markdown file '2024-11-13_n39_freies_hacken.md' generated successfully in the '../_events/2024/' folder! +Markdown file '2024-11-20_n39_freies_hacken.md' generated successfully in the '../_events/2024/' folder! +Markdown file '2024-11-27_n39_freies_hacken.md' generated successfully in the '../_events/2024/' folder! +Markdown file '2024-12-04_n39_freies_hacken.md' generated successfully in the '../_events/2024/' folder! +Markdown file '2024-12-11_n39_freies_hacken.md' generated successfully in the '../_events/2024/' folder! +Markdown file '2024-12-18_n39_freies_hacken.md' generated successfully in the '../_events/2024/' folder! +Markdown file '2024-12-25_n39_freies_hacken.md' generated successfully in the '../_events/2024/' folder! +``` From c1e9c490e9790ddfb4b58c8e8610d9d7f390b0ba Mon Sep 17 00:00:00 2001 From: timo Date: Thu, 9 Nov 2023 13:35:22 +0100 Subject: [PATCH 7/9] :truck: Rename Script --- ...te_freieshacken_events.py => generate_freies_hacken_events.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename tools/{generate_freieshacken_events.py => generate_freies_hacken_events.py} (100%) diff --git a/tools/generate_freieshacken_events.py b/tools/generate_freies_hacken_events.py similarity index 100% rename from tools/generate_freieshacken_events.py rename to tools/generate_freies_hacken_events.py From 04543d6907eb830a0fe03700fd20ed9858c05d1e Mon Sep 17 00:00:00 2001 From: timo Date: Thu, 9 Nov 2023 13:42:00 +0100 Subject: [PATCH 8/9] :bulb: Change comment --- tools/generate_freies_hacken_events.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/generate_freies_hacken_events.py b/tools/generate_freies_hacken_events.py index 668f0de..0c6f75a 100644 --- a/tools/generate_freies_hacken_events.py +++ b/tools/generate_freies_hacken_events.py @@ -15,6 +15,7 @@ folder_name = "_events" filename_prefix = "n39_freies_hacken" + # Function to generate the markdown content for a specific date def generate_markdown_file(year, month, day): markdown_content = f"""--- @@ -42,7 +43,7 @@ def generate_markdown_file(year, month, day): print(f"Usage: python3 {sys.argv[0]} ") sys.exit() -# Input year +# Get year from CLI year = int(sys.argv[1]) # Calculate Wednesdays From 83c443d144016ebdf5a98a876e1fd4f87061ffbe Mon Sep 17 00:00:00 2001 From: timo Date: Thu, 9 Nov 2023 13:45:34 +0100 Subject: [PATCH 9/9] :pencil2: Fix indentation --- tools/generate_freies_hacken_events.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/generate_freies_hacken_events.py b/tools/generate_freies_hacken_events.py index 0c6f75a..6151e44 100644 --- a/tools/generate_freies_hacken_events.py +++ b/tools/generate_freies_hacken_events.py @@ -40,8 +40,8 @@ def generate_markdown_file(year, month, day): if len(sys.argv) < 2: - print(f"Usage: python3 {sys.argv[0]} ") - sys.exit() + print(f"Usage: python3 {sys.argv[0]} ") + sys.exit() # Get year from CLI year = int(sys.argv[1])