Cache event list for faster presence checks
This commit is contained in:
parent
f0e5680f6c
commit
b36f4c741c
8
sync.py
8
sync.py
|
@ -19,18 +19,16 @@ for login, content in auth['logins'].items():
|
|||
logins[login] = caldav.DAVClient(url=content['url'], username=content['user'], password=content['password'])
|
||||
|
||||
cals = []
|
||||
cal_evts = {}
|
||||
for cal in auth['cals']:
|
||||
cals.append(caldav.Calendar(client = logins[cal['login']], url = cal['url']))
|
||||
cal_evts[cals[-1].canonical_url] = [ evt.vobject_instance.vevent.uid.value for evt in cals[-1].events() ]
|
||||
|
||||
changed = {}
|
||||
deleted = {}
|
||||
|
||||
def cal_contains_uid(cal, uid):
|
||||
try:
|
||||
event = cal.event_by_uid(uid)
|
||||
return True
|
||||
except caldav.lib.error.NotFoundError:
|
||||
return False
|
||||
return uid in cal_evts[cal.canonical_url]
|
||||
|
||||
for cal in cals:
|
||||
print("Checking %s" % (cal.canonical_url,))
|
||||
|
|
Loading…
Reference in New Issue
Block a user