2023-11-06 11:53:28 +01:00
|
|
|
import os
|
|
|
|
import datetime
|
|
|
|
|
2023-11-09 12:41:00 +01:00
|
|
|
layout = "event"
|
|
|
|
title = "Freies Hacken"
|
|
|
|
event_description = f"""
|
2023-11-06 11:53:28 +01:00
|
|
|
**Wann: 19:30 Uhr**\\
|
|
|
|
**Wo: Netz39 e.V.**
|
2023-11-09 12:41:00 +01:00
|
|
|
|
2023-11-06 11:53:28 +01:00
|
|
|
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.
|
2023-11-09 12:41:00 +01:00
|
|
|
"""
|
2023-11-09 13:01:20 +01:00
|
|
|
folder_name = "_events"
|
2023-11-09 12:41:00 +01:00
|
|
|
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}
|
2023-11-06 11:53:28 +01:00
|
|
|
"""
|
|
|
|
|
2023-11-09 13:01:20 +01:00
|
|
|
folder_path = f"../{folder_name}/{year}/"
|
2023-11-09 12:41:00 +01:00
|
|
|
filename = f"{year}-{month:02d}-{day:02d}_{filename_prefix}.md"
|
2023-11-06 11:53:28 +01:00
|
|
|
file_path = os.path.join(folder_path, filename)
|
|
|
|
|
2023-11-09 13:01:20 +01:00
|
|
|
if not os.path.exists(folder_path):
|
|
|
|
os.makedirs(folder_path)
|
|
|
|
|
2023-11-06 11:53:28 +01:00
|
|
|
with open(file_path, 'w', encoding='utf-8') as file:
|
|
|
|
file.write(markdown_content)
|
|
|
|
|
2023-11-09 13:01:20 +01:00
|
|
|
print(f"Markdown file '{filename}' generated successfully in the '{folder_path}' folder!")
|
2023-11-06 11:53:28 +01:00
|
|
|
|
|
|
|
|
|
|
|
# Input year
|
|
|
|
input_year = int(input("Enter the year: "))
|
|
|
|
|
2023-11-09 12:02:18 +01:00
|
|
|
# Calculate Wednesdays
|
2023-11-06 11:53:28 +01:00
|
|
|
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
|