diff --git a/Vacations/convert.py b/Vacations/convert.py index 4a7a5640164ac08ba03f65a320f4585b59afe636..13b6ad1f5b118ff7a2bafa99657d73b5eb5772b1 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())