Skip to content
Snippets Groups Projects
Commit dc255e76 authored by Yngve Levinsen's avatar Yngve Levinsen
Browse files

edits in convert script

parent 22404c4e
No related branches found
No related tags found
No related merge requests found
from icalendar import Calendar, Event
import codecs
import os
calendar_swe=Calendar()
calendar_swe.add('version', '2.0')
calendar_eng=calendar_swe.copy()
i_swe=1
i_eng=1
def create_event(summary, description, date, uid):
event=Event()
event['uid']=str(uid)
......@@ -15,23 +10,35 @@ def create_event(summary, description, date, uid):
event['summary']=summary
return event
for l in file('list.txt'):
# encoding issues with swedish:
l=codecs.decode(l, 'utf-8')
lsp=l.split(' ')
for f in os.listdir('.'):
if f.split('_')[0]=='list':
year=f.split('.')[0].split('_')[1]
print f,year
calendar_swe=Calendar()
calendar_swe.add('version', '2.0')
calendar_eng=calendar_swe.copy()
date=lsp[0].strip()
desc_eng=lsp[1].split('/')[0].strip()
desc_swe=lsp[1].split('/')[1].strip()
reduction=lsp[-1].strip()
event_swe=create_event(desc_swe, desc_swe+', '+reduction, date, i_swe)
i_swe+=1
calendar_swe.add_component(event_swe)
i_swe=1
i_eng=1
event_eng=create_event(desc_eng, desc_eng+', '+reduction, date, i_eng)
i_eng+=1
calendar_eng.add_component(event_eng)
for l in file(f):
# encoding issues with swedish:
l=codecs.decode(l, 'utf-8')
lsp=l.split(' ')
file('vacations_swe_2015.ics','w').writelines(calendar_swe.to_ical())
file('vacations_eng_2015.ics','w').writelines(calendar_eng.to_ical())
date=lsp[0].strip()
desc_eng=lsp[1].split('/')[0].strip()
desc_swe=lsp[1].split('/')[1].strip()
reduction=lsp[-1].strip()
event_swe=create_event(desc_swe, desc_swe+', '+reduction, date, i_swe)
i_swe+=1
calendar_swe.add_component(event_swe)
event_eng=create_event(desc_eng, desc_eng+', '+reduction, date, i_eng)
i_eng+=1
calendar_eng.add_component(event_eng)
file('vacations_swe_{}.ics'.format(year),'w').writelines(calendar_swe.to_ical())
file('vacations_eng_{}.ics'.format(year),'w').writelines(calendar_eng.to_ical())
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment