refac: ListManager naming convention
This commit is contained in:
parent
ac4aeeed7f
commit
246f8b8cac
3 changed files with 17 additions and 17 deletions
|
@ -122,7 +122,7 @@ async def list_calendar_names() -> list[str]:
|
||||||
return await CalDAV.calendars
|
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(
|
async def list_aggregate_names(
|
||||||
|
@ -138,4 +138,4 @@ async def list_aggregate_names(
|
||||||
return list(cfg.calendar.aggregates.keys())
|
return list(cfg.calendar.aggregates.keys())
|
||||||
|
|
||||||
|
|
||||||
LM_AGGREGATES = ListManager.from_lister_fn(list_aggregate_names)
|
LM_AGGREGATE = ListManager.from_lister_fn(list_aggregate_names)
|
||||||
|
|
|
@ -13,7 +13,7 @@ from fastapi import APIRouter, Depends
|
||||||
from ...core.caldav import CalDAV
|
from ...core.caldav import CalDAV
|
||||||
from ...core.calevent import CalEvent
|
from ...core.calevent import CalEvent
|
||||||
from ...core.config import Config
|
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__)
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -27,36 +27,36 @@ async def start_router() -> None:
|
||||||
|
|
||||||
@router.get(
|
@router.get(
|
||||||
"/list",
|
"/list",
|
||||||
responses=LM_AGGREGATES.lister.responses,
|
responses=LM_AGGREGATE.lister.responses,
|
||||||
)
|
)
|
||||||
async def list_aggregate_calendars(
|
async def list_aggregate_calendars(
|
||||||
names: list[str] = Depends(LM_AGGREGATES.lister.func),
|
names: list[str] = Depends(LM_AGGREGATE.lister.func),
|
||||||
) -> list[str]:
|
) -> list[str]:
|
||||||
return names
|
return names
|
||||||
|
|
||||||
|
|
||||||
@router.get(
|
@router.get(
|
||||||
"/find/{prefix}",
|
"/find/{prefix}",
|
||||||
responses=LM_AGGREGATES.filter.responses,
|
responses=LM_AGGREGATE.filter.responses,
|
||||||
)
|
)
|
||||||
async def find_aggregate_calendars(
|
async def find_aggregate_calendars(
|
||||||
names: list[str] = Depends(LM_AGGREGATES.filter.func),
|
names: list[str] = Depends(LM_AGGREGATE.filter.func),
|
||||||
) -> list[str]:
|
) -> list[str]:
|
||||||
return names
|
return names
|
||||||
|
|
||||||
|
|
||||||
@router.get(
|
@router.get(
|
||||||
"/get/{prefix}",
|
"/get/{prefix}",
|
||||||
responses=LM_AGGREGATES.getter.responses,
|
responses=LM_AGGREGATE.getter.responses,
|
||||||
)
|
)
|
||||||
async def get_aggregate_calendar(
|
async def get_aggregate_calendar(
|
||||||
cfg: Config = Depends(get_config),
|
cfg: Config = Depends(get_config),
|
||||||
name: str = Depends(LM_AGGREGATES.getter.func),
|
name: str = Depends(LM_AGGREGATE.getter.func),
|
||||||
) -> list[CalEvent]:
|
) -> list[CalEvent]:
|
||||||
events: list[CalEvent] = []
|
events: list[CalEvent] = []
|
||||||
|
|
||||||
for cal_prefix in cfg.calendar.aggregates[name]:
|
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))
|
events.extend(await CalDAV.get_events(cal_name, cfg))
|
||||||
|
|
||||||
return sorted(events)
|
return sorted(events)
|
||||||
|
|
|
@ -12,7 +12,7 @@ from fastapi import APIRouter, Depends
|
||||||
|
|
||||||
from ...core.caldav import CalDAV, CalEvent
|
from ...core.caldav import CalDAV, CalEvent
|
||||||
from ...core.config import CalendarUIConfig, Config
|
from ...core.config import CalendarUIConfig, Config
|
||||||
from ._common import LM_CALENDARS, get_config
|
from ._common import LM_CALENDAR, get_config
|
||||||
|
|
||||||
_logger = logging.getLogger(__name__)
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -26,30 +26,30 @@ async def start_router() -> None:
|
||||||
|
|
||||||
@router.get(
|
@router.get(
|
||||||
"/list",
|
"/list",
|
||||||
responses=LM_CALENDARS.lister.responses,
|
responses=LM_CALENDAR.lister.responses,
|
||||||
)
|
)
|
||||||
async def list_all_calendars(
|
async def list_all_calendars(
|
||||||
names: list[str] = Depends(LM_CALENDARS.lister.func),
|
names: list[str] = Depends(LM_CALENDAR.lister.func),
|
||||||
) -> list[str]:
|
) -> list[str]:
|
||||||
return names
|
return names
|
||||||
|
|
||||||
|
|
||||||
@router.get(
|
@router.get(
|
||||||
"/find/{prefix}",
|
"/find/{prefix}",
|
||||||
responses=LM_CALENDARS.filter.responses,
|
responses=LM_CALENDAR.filter.responses,
|
||||||
)
|
)
|
||||||
async def find_calendars(
|
async def find_calendars(
|
||||||
names: list[str] = Depends(LM_CALENDARS.filter.func),
|
names: list[str] = Depends(LM_CALENDAR.filter.func),
|
||||||
) -> list[str]:
|
) -> list[str]:
|
||||||
return names
|
return names
|
||||||
|
|
||||||
|
|
||||||
@router.get(
|
@router.get(
|
||||||
"/get/{prefix}",
|
"/get/{prefix}",
|
||||||
responses=LM_CALENDARS.getter.responses,
|
responses=LM_CALENDAR.getter.responses,
|
||||||
)
|
)
|
||||||
async def get_calendar(
|
async def get_calendar(
|
||||||
name: str = Depends(LM_CALENDARS.getter.func),
|
name: str = Depends(LM_CALENDAR.getter.func),
|
||||||
cfg: Config = Depends(get_config),
|
cfg: Config = Depends(get_config),
|
||||||
) -> list[CalEvent]:
|
) -> list[CalEvent]:
|
||||||
return await CalDAV.get_events(name, cfg)
|
return await CalDAV.get_events(name, cfg)
|
||||||
|
|
Loading…
Reference in a new issue