Skip to content

Commit 5fd152d

Browse files
committed
Add possibility to generate extra dates
1 parent bb183a6 commit 5fd152d

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

seminar/generate_mondays.py

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,19 @@ def find_next_monday(date: datetime.date):
2020
return on_day(date, 0)
2121

2222

23+
def generate_event_file(date: datetime.date, speaker: str, counter: int):
24+
next_monday: datetime.date = find_next_monday(date)
25+
file_name = str(next_monday) + "-talk" + str(counter) + ".md"
26+
output_file: Path = output_dir / file_name
27+
output_file.write_text(template.substitute(speaker=speaker))
28+
print("Created " + str(output_file))
29+
30+
2331
############
2432
# Input data
2533
############
2634
start_date: datetime.date = datetime.date(2023, 11, 14)
27-
output_dir: Path = Path("./seminar/2324/_posts")
35+
output_dir: Path = Path("./seminar/test/_posts")
2836
speakers: list[str] = [
2937
"Gerson Sunyé",
3038
"Massimo Tisi",
@@ -41,28 +49,30 @@ def find_next_monday(date: datetime.date):
4149
"James Miranda",
4250
]
4351
random.shuffle(speakers)
52+
extra_dates: int = 5
4453

4554
############
4655
# Preparations
4756
############
4857
output_dir.mkdir(parents=True, exist_ok=True)
4958
example_file: Path = Path("./seminar/talk_template.md")
5059
if not example_file.exists():
51-
raise "Missing example file at location " + str(example_file)
60+
raise Exception("Missing example file at location " + str(example_file))
5261

5362
template: Template = Template(example_file.read_text())
5463

5564
############
5665
# Loop
5766
############
58-
current_date = start_date + datetime.timedelta(days=1)
67+
current_date = find_next_monday(start_date + datetime.timedelta(days=1))
5968
counter: int = 1
6069

6170
for speaker in speakers:
62-
next_monday: datetime.date = find_next_monday(current_date)
63-
file_name = str(next_monday) + "-talk" + str(counter) + ".md"
71+
generate_event_file(current_date, speaker, counter)
6472
counter = counter + 1
65-
output_file: Path = output_dir / file_name
66-
output_file.write_text(template.substitute(speaker=speaker))
67-
print("Created " + str(output_file))
68-
current_date = next_monday + datetime.timedelta(days=1)
73+
current_date = find_next_monday(current_date + datetime.timedelta(days=1))
74+
75+
for extra in range(0, extra_dates):
76+
generate_event_file(current_date, "TBA", counter)
77+
counter = counter + 1
78+
current_date = find_next_monday(current_date + datetime.timedelta(days=1))

0 commit comments

Comments
 (0)