From 7b9b8d9b32a6084e1c348312357cc6ae1e596655 Mon Sep 17 00:00:00 2001 From: Yngve Levinsen <yngve@pm.me> Date: Thu, 29 Nov 2018 08:31:11 +0100 Subject: [PATCH] skip older vacations --- Vacations/convert.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/Vacations/convert.py b/Vacations/convert.py index 4a7a564..13b6ad1 100644 --- a/Vacations/convert.py +++ b/Vacations/convert.py @@ -17,7 +17,7 @@ i_eng_all=1 for f in os.listdir('.'): if f.split('_')[0]=='list': - year=f.split('.')[0].split('_')[1] + year=int(f.split('.')[0].split('_')[1]) print(f,year) calendar_swe=Calendar() @@ -28,6 +28,8 @@ for f in os.listdir('.'): i_eng=1 for l in open(f, 'r', encoding="utf8"): + if l.strip()[0]=='#': + continue # encoding issues with swedish: lsp=l.split(' ') @@ -44,13 +46,14 @@ for f in os.listdir('.'): i_eng+=1 calendar_eng.add_component(event_eng) - event_swe_all=create_event(desc_swe, desc_swe+', '+reduction, date, i_swe_all) - i_swe_all+=1 - calendar_swe_all.add_component(event_swe_all) + if year>2016: + event_swe_all=create_event(desc_swe, desc_swe+', '+reduction, date, i_swe_all) + i_swe_all+=1 + calendar_swe_all.add_component(event_swe_all) - event_eng_all=create_event(desc_eng, desc_eng+', '+reduction, date, i_eng_all) - i_eng_all+=1 - calendar_eng_all.add_component(event_eng_all) + event_eng_all=create_event(desc_eng, desc_eng+', '+reduction, date, i_eng_all) + i_eng_all+=1 + calendar_eng_all.add_component(event_eng_all) open('vacations_swe_{}.ics'.format(year),'wb').write(calendar_swe.to_ical()) open('vacations_eng_{}.ics'.format(year),'wb').write(calendar_eng.to_ical()) -- GitLab