@@ -67,12 +67,11 @@ def convert_to_ical(file_paths: list[str], output_path: str, lang: str='en', SUB
6767 year = conf ['year' ]
6868 link = conf ['link' ]
6969 timeline = conf ['timeline' ]
70- timezone = conf ['timezone' ]
70+ timezone_str = conf ['timezone' ]
7171 place = conf ['place' ]
7272 date = conf ['date' ]
7373
7474 for entry in timeline :
75- timezone_str = conf ['timezone' ]
7675 try :
7776 tz = get_timezone (timezone_str )
7877 except ValueError :
@@ -88,97 +87,107 @@ def convert_to_ical(file_paths: list[str], output_path: str, lang: str='en', SUB
8887 cal .add_component (vtz )
8988 added_tzids .add (tzid )
9089
91- # 判断截止类型
92- deadline_type , deadline_str = None , None
90+ # 收集所有需要处理的截止日期
91+ deadlines_to_process = []
92+
9393 if 'abstract_deadline' in entry :
94- deadline_type = ('摘要截稿' , 'Abstract Deadline' )
95- deadline_str = entry ['abstract_deadline' ]
96- elif 'deadline' in entry :
97- deadline_type = ('截稿日期' , 'Deadline' )
98- deadline_str = entry ['deadline' ]
99- else :
100- continue # 跳过无效条目
101-
102- if deadline_str == 'TBD' :
103- continue # 忽略待定日期
104-
105- # 解析日期和时间
106- is_all_day = False
107- try :
108- deadline_dt = datetime .strptime (deadline_str , '%Y-%m-%d %H:%M:%S' )
109- except ValueError :
94+ deadlines_to_process .append ((
95+ ('摘要截稿' , 'Abstract Deadline' ),
96+ entry ['abstract_deadline' ]
97+ ))
98+
99+ if 'deadline' in entry :
100+ deadlines_to_process .append ((
101+ ('截稿日期' , 'Deadline' ),
102+ entry ['deadline' ]
103+ ))
104+
105+ # 如果没有任何截止日期,跳过
106+ if not deadlines_to_process :
107+ continue
108+
109+ # 处理每个截止日期
110+ for deadline_type , deadline_str in deadlines_to_process :
111+ if deadline_str == 'TBD' :
112+ continue # 忽略待定日期
113+
114+ # 解析日期和时间
115+ is_all_day = False
110116 try :
111- deadline_dt = datetime .strptime (deadline_str , '%Y-%m-%d' )
112- is_all_day = True
117+ deadline_dt = datetime .strptime (deadline_str , '%Y-%m-%d %H:%M:%S' )
113118 except ValueError :
114- continue # 无效日期格式
115-
116- # 创建事件对象
117- event = Event ()
118- event .add ('uid' , uuid .uuid4 ())
119- event .add ('dtstamp' , datetime .now (get_timezone (timezone ))) # UTC时区感知
120-
121- # 处理时间字段
122- if is_all_day :
123- event .add ('dtstart' , deadline_dt .date ())
124- event .add ('dtend' , (deadline_dt + timedelta (days = 1 )).date ())
125- else :
126- aware_dt = deadline_dt .replace (tzinfo = tz )
127- event .add ('dtstart' , aware_dt )
128- event .add ('dtend' , aware_dt + timedelta (minutes = 1 ))
129-
130- # 构建中英双语摘要
131- if lang == 'en' :
132- summary = f"{ title } { year } { deadline_type [1 ]} "
133- else :
134- summary = f"{ title } { year } { deadline_type [0 ]} "
135-
136- # 添加注释信息
137- if 'comment' in entry :
138- summary += f" [{ entry ['comment' ]} ]"
139- event .add ('summary' , summary )
140-
141- # 构建详细描述
142- level_desc = [
143- f"CCF { rank ['ccf' ]} " if rank ['ccf' ] != "N" else None ,
144- f"CORE { rank ['core' ]} " if rank .get ('core' , 'N' ) != "N" else None ,
145- f"THCPL { rank ['thcpl' ]} " if rank .get ('thcpl' , 'N' ) != "N" else None ,
146- ]
147- level_desc = [line for line in level_desc if line ]
148- if len (level_desc ) > 0 :
149- level_desc = ", " .join (level_desc )
150- else :
151- level_desc = None
152- if lang == 'en' :
153- description = [
154- f"{ conf_data ['description' ]} " ,
155- f"🗓️ Date: { date } " ,
156- f"📍 Location: { place } " ,
157- f"⏰ Original Deadline ({ timezone } ): { deadline_str } " ,
158- f"Category: { sub_chinese } ({ sub } )" ,
159- level_desc ,
160- f"Conference Website: { link } " ,
161- f"DBLP Index: https://dblp.org/db/conf/{ dblp } " ,
162- ]
163- else :
164- description = [
165- f"{ conf_data ['description' ]} " ,
166- f"🗓️ 会议时间: { date } " ,
167- f"📍 会议地点: { place } " ,
168- f"⏰ 原始截止时间 ({ timezone } ): { deadline_str } " ,
169- f"分类: { sub_chinese } ({ sub } )" ,
170- level_desc ,
171- f"会议官网: { link } " ,
172- f"DBLP索引: https://dblp.org/db/conf/{ dblp } " ,
119+ try :
120+ deadline_dt = datetime .strptime (deadline_str , '%Y-%m-%d' )
121+ is_all_day = True
122+ except ValueError :
123+ continue # 无效日期格式
124+
125+ # 创建事件对象
126+ event = Event ()
127+ event .add ('uid' , uuid .uuid4 ())
128+ event .add ('dtstamp' , datetime .now (tz ))
129+
130+ # 处理时间字段
131+ if is_all_day :
132+ event .add ('dtstart' , deadline_dt .date ())
133+ event .add ('dtend' , (deadline_dt + timedelta (days = 1 )).date ())
134+ else :
135+ aware_dt = deadline_dt .replace (tzinfo = tz )
136+ event .add ('dtstart' , aware_dt )
137+ event .add ('dtend' , aware_dt + timedelta (minutes = 1 ))
138+
139+ # 构建中英双语摘要
140+ if lang == 'en' :
141+ summary = f"{ title } { year } { deadline_type [1 ]} "
142+ else :
143+ summary = f"{ title } { year } { deadline_type [0 ]} "
144+
145+ # 添加注释信息
146+ if 'comment' in entry :
147+ summary += f" [{ entry ['comment' ]} ]"
148+ event .add ('summary' , summary )
149+
150+ # 构建详细描述
151+ level_desc = [
152+ f"CCF { rank ['ccf' ]} " if rank ['ccf' ] != "N" else None ,
153+ f"CORE { rank ['core' ]} " if rank .get ('core' , 'N' ) != "N" else None ,
154+ f"THCPL { rank ['thcpl' ]} " if rank .get ('thcpl' , 'N' ) != "N" else None ,
173155 ]
174- description = [line for line in description if line ]
175- event .add ('description' , '\n ' .join (description ))
176-
177- # 添加其他元信息
178- event .add ('location' , place )
179- event .add ('url' , link )
180-
181- cal .add_component (event )
156+ level_desc = [line for line in level_desc if line ]
157+ if len (level_desc ) > 0 :
158+ level_desc = ", " .join (level_desc )
159+ else :
160+ level_desc = None
161+ if lang == 'en' :
162+ description = [
163+ f"{ conf_data ['description' ]} " ,
164+ f"🗓️ Date: { date } " ,
165+ f"📍 Location: { place } " ,
166+ f"⏰ Original Deadline ({ timezone_str } ): { deadline_str } " ,
167+ f"Category: { sub_chinese } ({ sub } )" ,
168+ level_desc ,
169+ f"Conference Website: { link } " ,
170+ f"DBLP Index: https://dblp.org/db/conf/{ dblp } " ,
171+ ]
172+ else :
173+ description = [
174+ f"{ conf_data ['description' ]} " ,
175+ f"🗓️ 会议时间: { date } " ,
176+ f"📍 会议地点: { place } " ,
177+ f"⏰ 原始截止时间 ({ timezone_str } ): { deadline_str } " ,
178+ f"分类: { sub_chinese } ({ sub } )" ,
179+ level_desc ,
180+ f"会议官网: { link } " ,
181+ f"DBLP索引: https://dblp.org/db/conf/{ dblp } " ,
182+ ]
183+ description = [line for line in description if line ]
184+ event .add ('description' , '\n ' .join (description ))
185+
186+ # 添加其他元信息
187+ event .add ('location' , place )
188+ event .add ('url' , link )
189+
190+ cal .add_component (event )
182191
183192 # 写入输出文件
184193 with open (output_path , 'wb' ) as f :
0 commit comments