refac: ListManager naming convention

This commit is contained in:
Jörn-Michael Miehe 2023-10-26 19:17:16 +02:00
parent ac4aeeed7f
commit 246f8b8cac
3 changed files with 17 additions and 17 deletions

View file

@ -122,7 +122,7 @@ async def list_calendar_names() -> list[str]:
return await CalDAV.calendars
LM_CALENDARS = ListManager.from_lister_fn(list_calendar_names)
LM_CALENDAR = ListManager.from_lister_fn(list_calendar_names)
async def list_aggregate_names(
@ -138,4 +138,4 @@ async def list_aggregate_names(
return list(cfg.calendar.aggregates.keys())
LM_AGGREGATES = ListManager.from_lister_fn(list_aggregate_names)
LM_AGGREGATE = ListManager.from_lister_fn(list_aggregate_names)

View file

@ -13,7 +13,7 @@ from fastapi import APIRouter, Depends
from ...core.caldav import CalDAV
from ...core.calevent import CalEvent
from ...core.config import Config
from ._common import LM_AGGREGATES, LM_CALENDARS, get_config
from ._common import LM_AGGREGATE, LM_CALENDAR, get_config
_logger = logging.getLogger(__name__)
@ -27,36 +27,36 @@ async def start_router() -> None:
@router.get(
"/list",
responses=LM_AGGREGATES.lister.responses,
responses=LM_AGGREGATE.lister.responses,
)
async def list_aggregate_calendars(
names: list[str] = Depends(LM_AGGREGATES.lister.func),
names: list[str] = Depends(LM_AGGREGATE.lister.func),
) -> list[str]:
return names
@router.get(
"/find/{prefix}",
responses=LM_AGGREGATES.filter.responses,
responses=LM_AGGREGATE.filter.responses,
)
async def find_aggregate_calendars(
names: list[str] = Depends(LM_AGGREGATES.filter.func),
names: list[str] = Depends(LM_AGGREGATE.filter.func),
) -> list[str]:
return names
@router.get(
"/get/{prefix}",
responses=LM_AGGREGATES.getter.responses,
responses=LM_AGGREGATE.getter.responses,
)
async def get_aggregate_calendar(
cfg: Config = Depends(get_config),
name: str = Depends(LM_AGGREGATES.getter.func),
name: str = Depends(LM_AGGREGATE.getter.func),
) -> list[CalEvent]:
events: list[CalEvent] = []
for cal_prefix in cfg.calendar.aggregates[name]:
cal_name = await LM_CALENDARS.getter.func(cal_prefix)
cal_name = await LM_CALENDAR.getter.func(cal_prefix)
events.extend(await CalDAV.get_events(cal_name, cfg))
return sorted(events)

View file

@ -12,7 +12,7 @@ from fastapi import APIRouter, Depends
from ...core.caldav import CalDAV, CalEvent
from ...core.config import CalendarUIConfig, Config
from ._common import LM_CALENDARS, get_config
from ._common import LM_CALENDAR, get_config
_logger = logging.getLogger(__name__)
@ -26,30 +26,30 @@ async def start_router() -> None:
@router.get(
"/list",
responses=LM_CALENDARS.lister.responses,
responses=LM_CALENDAR.lister.responses,
)
async def list_all_calendars(
names: list[str] = Depends(LM_CALENDARS.lister.func),
names: list[str] = Depends(LM_CALENDAR.lister.func),
) -> list[str]:
return names
@router.get(
"/find/{prefix}",
responses=LM_CALENDARS.filter.responses,
responses=LM_CALENDAR.filter.responses,
)
async def find_calendars(
names: list[str] = Depends(LM_CALENDARS.filter.func),
names: list[str] = Depends(LM_CALENDAR.filter.func),
) -> list[str]:
return names
@router.get(
"/get/{prefix}",
responses=LM_CALENDARS.getter.responses,
responses=LM_CALENDAR.getter.responses,
)
async def get_calendar(
name: str = Depends(LM_CALENDARS.getter.func),
name: str = Depends(LM_CALENDAR.getter.func),
cfg: Config = Depends(get_config),
) -> list[CalEvent]:
return await CalDAV.get_events(name, cfg)