@@ -20,11 +20,19 @@ def find_next_monday(date: datetime.date):
20
20
return on_day (date , 0 )
21
21
22
22
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
+
23
31
############
24
32
# Input data
25
33
############
26
34
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" )
28
36
speakers : list [str ] = [
29
37
"Gerson Sunyé" ,
30
38
"Massimo Tisi" ,
@@ -41,28 +49,30 @@ def find_next_monday(date: datetime.date):
41
49
"James Miranda" ,
42
50
]
43
51
random .shuffle (speakers )
52
+ extra_dates : int = 5
44
53
45
54
############
46
55
# Preparations
47
56
############
48
57
output_dir .mkdir (parents = True , exist_ok = True )
49
58
example_file : Path = Path ("./seminar/talk_template.md" )
50
59
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 ) )
52
61
53
62
template : Template = Template (example_file .read_text ())
54
63
55
64
############
56
65
# Loop
57
66
############
58
- current_date = start_date + datetime .timedelta (days = 1 )
67
+ current_date = find_next_monday ( start_date + datetime .timedelta (days = 1 ) )
59
68
counter : int = 1
60
69
61
70
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 )
64
72
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