make get_items and convert_to_feed_item methods private
Some checks failed
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is failing

This commit is contained in:
mitsuha_s 2022-05-29 23:00:59 +00:00
parent ba2ff845d3
commit fa0632e84d

10
rss.py
View file

@ -8,12 +8,12 @@ class FeedItem():
self.description = description self.description = description
class Feed(): class Feed():
def __init__(self, url: str, items: list) -> None: def __init__(self, url: str, items: list[FeedItem]) -> None:
self.url = url self.url = url
self.items = items self.items = items
class RssReader(): class RssReader():
def convert_to_FeedItem(self, item: dict) -> FeedItem: def __convert_to_feed_item(self, item: dict) -> FeedItem:
if 'title' in item: if 'title' in item:
title = item['title'] title = item['title']
if 'link' in item: if 'link' in item:
@ -22,13 +22,13 @@ class RssReader():
description = item['summary'] description = item['summary']
return FeedItem(url, title, description) return FeedItem(url, title, description)
def get_items(self, items: list) -> list: def __get_items(self, items: list) -> list:
list_items = [] list_items = []
for item in items: for item in items:
list_items.append(self.convert_to_FeedItem(item)) list_items.append(self.__convert_to_feed_item(item))
return list_items return list_items
def get_feed(self, url: str) -> Feed: def get_feed(self, url: str) -> Feed:
f = feedparser.parse(url) f = feedparser.parse(url)
items = self.get_items(f.entries) items = self.__get_items(f.entries)
return Feed(url, items) return Feed(url, items)