mirror of
https://github.com/netz39/www.netz39.de.git
synced 2025-01-19 12:20:12 +01:00
🎨 Add CLI Parameter
This commit is contained in:
parent
07dc648237
commit
145a61e1aa
1 changed files with 8 additions and 3 deletions
|
@ -1,5 +1,6 @@
|
||||||
import os
|
import os
|
||||||
import datetime
|
import datetime
|
||||||
|
import sys
|
||||||
|
|
||||||
layout = "event"
|
layout = "event"
|
||||||
title = "Freies Hacken"
|
title = "Freies Hacken"
|
||||||
|
@ -37,19 +38,23 @@ event_date: {year}-{month:02d}-{day:02d}
|
||||||
print(f"Markdown file '{filename}' generated successfully in the '{folder_path}' folder!")
|
print(f"Markdown file '{filename}' generated successfully in the '{folder_path}' folder!")
|
||||||
|
|
||||||
|
|
||||||
|
if len(sys.argv) < 2:
|
||||||
|
print(f"Usage: python3 {sys.argv[0]} <year>")
|
||||||
|
sys.exit()
|
||||||
|
|
||||||
# Input year
|
# Input year
|
||||||
input_year = int(input("Enter the year: "))
|
year = int(sys.argv[1])
|
||||||
|
|
||||||
# Calculate Wednesdays
|
# Calculate Wednesdays
|
||||||
for month in range(1, 13):
|
for month in range(1, 13):
|
||||||
for day in range(1, 32):
|
for day in range(1, 32):
|
||||||
try:
|
try:
|
||||||
# Generate a date object
|
# 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
|
# Check if the date is a Wednesday
|
||||||
if current_date.weekday() == 2:
|
if current_date.weekday() == 2:
|
||||||
generate_markdown_file(input_year, month, day)
|
generate_markdown_file(year, month, day)
|
||||||
|
|
||||||
except ValueError:
|
except ValueError:
|
||||||
# If the day is out of range for the month, skip to the next month
|
# If the day is out of range for the month, skip to the next month
|
||||||
|
|
Loading…
Reference in a new issue