sync principal

This commit is contained in:
Jörn-Michael Miehe 2022-09-04 14:14:22 +00:00
parent 559803ac0e
commit f6937b5075
3 changed files with 2 additions and 7 deletions

View file

@ -48,6 +48,5 @@ _CALDAV_CLIENT = caldav.DAVClient(
)
@run_in_executor
def caldav_principal() -> caldav.Principal:
return _CALDAV_CLIENT.principal()

View file

@ -37,11 +37,9 @@ class FileNameLister:
@dataclass(frozen=True)
class CalendarNameLister:
async def __call__(self) -> Iterator[str]:
principal = await caldav_principal()
return (
cal.name
for cal in principal.calendars()
for cal in caldav_principal().calendars()
)

View file

@ -1,7 +1,6 @@
from datetime import datetime, timedelta
from typing import Iterator
import caldav
from fastapi import APIRouter, Depends, HTTPException, status
from .. import caldav_principal
@ -39,8 +38,7 @@ async def get_calendar(
elif len(calendar_names) > 1:
raise HTTPException(status_code=status.HTTP_409_CONFLICT)
principal: caldav.Principal = await caldav_principal()
calendar = principal.calendar(name=calendar_names[0])
calendar = caldav_principal().calendar(name=calendar_names[0])
events = []