Commit 0e797af4 authored by mit's avatar mit

pep8

parent 79c636a9
......@@ -104,7 +104,6 @@ class Event:
def caldav(self, caldav):
self._caldav = caldav
def compute_vlines(self, cul):
start_hour = int(self.date.strftime('%H'))
start_min = int(self.date.strftime('%M'))
......@@ -334,6 +333,7 @@ def Agenda2Cul(agenda, categories, default_tag, caldav=None):
cal.add_event(e)
return cal
def event2icalevent(e, categories=None):
ie = icalendar.Event()
ie.add('dtstart', e.date)
......@@ -350,11 +350,12 @@ def event2icalevent(e, categories=None):
ie.add('uid', e.uid)
return ie
def export_ical(cal, filename, categories):
ical = icalendar.Calendar()
ical.add('prodid', '-//From Culendar')
ical.add('version', '2.0')
for e in cal.events:
ie = event2icalevent(e, categories)
ical.add_component(ie)
......
......@@ -6,6 +6,7 @@ import icalendar
from . import calendar
from urllib.request import urlopen
class Cdav:
def __init__(self, caldav_dict, screen, day):
self._list = caldav_dict
......@@ -118,6 +119,7 @@ def del_event(event):
url = event.caldav.url.url_raw+event.uid+".ics"
event.caldav.event_by_url(url).delete()
def add_event(event, cdav):
event.uid = "cul_"+str(hash(event))
event.caldav = cdav
......
......@@ -255,7 +255,6 @@ class Culendar:
self.update()
self.clear_footer()
else:
# delete from local cal in order to
# avoid syncing caldav to update events
# inform when deleting is slow
......@@ -294,7 +293,7 @@ class Culendar:
if key == "KEY_RESIZE":
self.update()
self.clear_footer()
return # exit here
return # exit here
# the footer will be useful, clear it
self.clear_footer()
......@@ -345,7 +344,7 @@ class Culendar:
self._calweek = calendar.extract_week(self._cal, self._caldav,
self._day, self,
autosync=0)
if event.caldav: # update the corresponding caldav
if event.caldav: # update the corresponding caldav
culdav.del_event(event)
culdav.add_event(event, event.caldav)
# redraw full day
......@@ -494,15 +493,15 @@ class Culendar:
if prekey == "KEY_RESIZE":
self.update()
key = prekey[0]
if key.isdigit() and (0 <= int(key) <= 7): # local event
if key.isdigit() and (0 <= int(key) <= 7): # local event
event.tag = key
self.clear_footer()
elif key.isalpha(): # caldav event
elif key.isalpha(): # caldav event
if key in self._caldav._tags:
idx = self._caldav._tags.index(key)
caldav = self._caldav._icals[idx]
if self._caldav._iscaldav[idx]: # caldav
if self._caldav._iscaldav[idx]: # caldav
# switch from local to caldav local culendars
event.tag = key
self._cal.del_event(event)
......@@ -513,7 +512,7 @@ class Culendar:
msg = _("Event moved to ")
url = caldav.url.url_raw
self.inform(msg+url)
else: # it's a webcal, read-only
else: # it's a webcal, read-only
msg = _("Error: can't add an event to a webcal")
self._screen.addstr(self._ymax-2, 0, msg)
self._screen.addstr(self._ymax-1, 0,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment