MCPcopy Index your code
hub / github.com/ndleah/python-mini-project / Feed

Class Feed

RSS_Manager/utils.py:67–91  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

65
66
67class Feed:
68 def __init__(self, url: str, tag: str | None = None) -> None:
69 self.feed_parse = feedparser.parse(url)
70 self.title: str = self.feed_parse.feed.title
71 self.link: str = self.feed_parse.feed.link
72 self.rss_feed: str = url
73 self.tag: str | None = tag
74
75 def articles(self) -> List[Dict[str, str]]:
76 """list all the articles of Feed"""
77 articles = []
78 for entry in self.feed_parse.entries:
79 article = {
80 "title": entry.title,
81 "link": entry.link,
82 "published_parsed": datetime(*entry.published_parsed[:6]),
83 }
84 articles.append(article)
85 return articles
86
87 def __str__(self) -> str:
88 return f"{self.title} -> {self.link}"
89
90 def __repr__(self) -> str:
91 return f"Feed({self.title})"

Callers 2

add_feed_submitFunction · 0.90
get_articles_for_feedFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected