Explorar o código

Rename config key 'calendars' to 'ical_feeds'

Matches the module that consumes it.
ZiB hai 4 meses
pai
achega
53af4aa1ea

+ 2 - 2
room_cal/_utils.py

@@ -404,7 +404,7 @@ class Config:
   global_: GlobalConfig = field(default_factory=GlobalConfig)
   services: dict[str, ServiceConfig] = field(default_factory=dict)
   rules: RulesConfig = field(default_factory=RulesConfig)
-  calendars: list[CalendarEntry] = field(default_factory=list)
+  ical_feeds: list[CalendarEntry] = field(default_factory=list)
   api_url: str | None = None
   store: StoreConfig = field(default_factory=StoreConfig)
   reservation: ReservationConfig = field(default_factory=ReservationConfig)
@@ -417,7 +417,7 @@ class Config:
       global_=GlobalConfig.from_dict(d.get('global', {})),
       services={k: ServiceConfig.from_dict(k, v) for k, v in d.get('services', {}).items()},
       rules=RulesConfig.from_dict(d.get('rules', {})),
-      calendars=[CalendarEntry.from_dict(e) for e in d.get('calendars', [])],
+      ical_feeds=[CalendarEntry.from_dict(e) for e in d.get('ical_feeds', [])],
       api_url=d.get('api_url'),
       store=StoreConfig.from_dict(store_d),
       reservation=ReservationConfig.from_dict(d.get('reservation', {})),

+ 1 - 1
room_cal/actions/diff.py

@@ -352,7 +352,7 @@ async def _diff_ical_feeds_closed(
   """
   from room_cal.ical_feeds import fetch_calendar
 
-  entries = get_config().calendars
+  entries = get_config().ical_feeds
   if not entries:
     return {}
 

+ 1 - 1
room_cal/actions/fetch_feed.py

@@ -23,7 +23,7 @@ async def fetch_feed(
   """
   from room_cal.ical_feeds import fetch_calendar
 
-  entries = get_config().calendars
+  entries = get_config().ical_feeds
   entry = next((e for e in entries if e.name == feed_name), None)
   if entry is None:
     raise ValueError(f"No ical feed configured with name {feed_name!r}")

+ 1 - 1
room_cal/actions/local_sync.py

@@ -22,7 +22,7 @@ async def local_sync(start_date: date, end_date: date) -> None:
   from room_cal.actions.fill_prices import fill_prices
   from room_cal.actions.apply_rules import apply_rules
 
-  for entry in get_config().calendars:
+  for entry in get_config().ical_feeds:
     result = await fetch_feed(start_date, end_date, feed_name=entry.name)
     _log.info("feed %r: %d date(s) closed%s", entry.name, len(result.data), " (changed)" if result.changed else "")
 

+ 1 - 1
room_cal/config-all.json

@@ -111,7 +111,7 @@
       }
     }
   },
-  "calendars": [
+  "ical_feeds": [
     {
       "name": "Fire",
       "url": "webcal://cal.4114.us/fire.ics"

+ 1 - 1
room_cal/config.json

@@ -43,7 +43,7 @@
       "special_events": {"type": "price",    "rules": ["fire"]}
     }
   },
-  "calendars": [
+  "ical_feeds": [
     {
       "name": "Fire",
       "url": "webcal://cal.4114.us/fire.ics"

+ 1 - 1
room_cal/ical_feeds/__init__.py

@@ -68,6 +68,6 @@ async def fetch_calendar(entry: CalendarEntry) -> list[EventRecord]:
 async def fetch_all() -> dict[str, list[EventRecord]]:
   """Fetch all configured external calendars. Returns {name: [events]}."""
   results = {}
-  for entry in get_config().calendars:
+  for entry in get_config().ical_feeds:
     results[entry.name] = await fetch_calendar(entry)
   return results

+ 1 - 1
room_cal/rules/price/fire.py

@@ -15,7 +15,7 @@ RULE_NAME = 'fire'
 async def run(start_date: date, end_date: date, data: PriceRuleList) -> PriceRuleList:
   cfg = get_config().rules.fire
   feed_entry = next(
-    (e for e in get_config().calendars if e.name == cfg.feed_name),
+    (e for e in get_config().ical_feeds if e.name == cfg.feed_name),
     None,
   )
   if feed_entry is None: