6 from typing import Dict, List, Optional
9 from dateutil.parser import parse
11 import generic_news_rss_renderer as gnrss
14 logger = logging.getLogger(__name__)
17 class bellevue_city_calendar_renderer(gnrss.generic_news_rss_renderer):
18 """Read the Bellevue City Calendar feed."""
22 name_to_timeout_dict: Dict[str, int],
27 super().__init__(name_to_timeout_dict, feed_site, feed_uris, page_title)
29 def get_headlines_page_prefix(self) -> str:
30 return "bellevue-calendar"
32 def get_details_page_prefix(self) -> str:
33 return "bellevue-calendar-details"
35 def should_use_https(self) -> bool:
39 self, item: xml.etree.ElementTree.Element
40 ) -> Optional[datetime.datetime]:
41 return parse(self.find_pubdate(item))
43 def find_pubdate(self, item: xml.etree.ElementTree.Element) -> Optional[str]:
44 descr = item.findtext("description")
47 m = re.search(r'time datetime="([^"]+)"', descr)
52 def item_is_interesting_for_headlines(
53 self, title: str, description: str, item: xml.etree.ElementTree.Element
55 if "City Council" in title:
57 if "City Offices Closed" in title:
59 if "Regular Meeting" in title:
61 if "Commission" in title:
63 date = self.get_event_time(item)
67 now = datetime.datetime.now(tzinfo)
68 delta = (now - date).total_seconds() / (60 * 60 * 24)
71 def do_details(self) -> bool:
72 logger.debug("No Bellevue city calendar items are interesting for articles...")
75 def item_is_interesting_for_article(
76 self, title: str, description: str, item: xml.etree.ElementTree.Element
78 logger.debug("No Bellevue city calendar items are interesting for articles...")
83 # x = bellevue_city_calendar_renderer(
85 # "Shuffle News" : 1},
87 # [ "/calendar/events.xml" ],
89 # if x.fetch_news() == 0:
90 # print("Error fetching news, no items fetched.")