Преглед на файлове

Change get_main/top_article to class methods

jherve преди 1 година
родител
ревизия
7de4afd9ec

+ 4 - 4
src/media_observer/article.py

@@ -138,13 +138,13 @@ class FrontPage(ABC):
     top_articles: list[TopArticle]
     main_article: MainArticle
 
-    @staticmethod
+    @classmethod
     @abstractmethod
-    def get_top_articles(soup: MagnificentSoup) -> list[TopArticle]: ...
+    def get_top_articles(cls, soup: MagnificentSoup) -> list[TopArticle]: ...
 
-    @staticmethod
+    @classmethod
     @abstractmethod
-    def get_main_article(soup: MagnificentSoup) -> MainArticle: ...
+    def get_main_article(cls, soup: MagnificentSoup) -> MainArticle: ...
 
     @classmethod
     async def from_snapshot(cls, snapshot: InternetArchiveSnapshot):

+ 4 - 4
src/media_observer/medias/bfmtv.py

@@ -6,8 +6,8 @@ from media_observer.article import (
 
 
 class BfmTvFrontPage(FrontPage):
-    @staticmethod
-    def get_top_articles(soup):
+    @classmethod
+    def get_top_articles(cls, soup):
         all_articles = soup.select("section[id*='top_contenus'] li > a")
         return [
             TopArticle.create(
@@ -18,8 +18,8 @@ class BfmTvFrontPage(FrontPage):
             for idx, a in enumerate(all_articles)
         ]
 
-    @staticmethod
-    def get_main_article(soup):
+    @classmethod
+    def get_main_article(cls, soup):
         main = soup.select_unique("article.une_item")
         return MainArticle.create(
             title=main.select_unique("h2.title_une_item").stripped_text,

+ 4 - 4
src/media_observer/medias/cnews.py

@@ -8,8 +8,8 @@ from media_observer.article import (
 
 
 class CNewsFrontPage(FrontPage):
-    @staticmethod
-    def get_top_articles(soup: BeautifulSoup):
+    @classmethod
+    def get_top_articles(cls, soup: BeautifulSoup):
         all_articles = soup.select(".top-news-content a")
 
         return [
@@ -21,8 +21,8 @@ class CNewsFrontPage(FrontPage):
             for idx, a in enumerate(all_articles)
         ]
 
-    @staticmethod
-    def get_main_article(soup):
+    @classmethod
+    def get_main_article(cls, soup):
         main = soup.select_first("div.dm-block")
         url = main.select_unique("a")
 

+ 4 - 4
src/media_observer/medias/france_tv_info.py

@@ -6,8 +6,8 @@ from media_observer.article import (
 
 
 class FranceTvInfoFrontPage(FrontPage):
-    @staticmethod
-    def get_top_articles(soup):
+    @classmethod
+    def get_top_articles(cls, soup):
         all_articles = soup.select("article.card-article-most-read")
 
         return [
@@ -19,8 +19,8 @@ class FranceTvInfoFrontPage(FrontPage):
             for idx, a in enumerate(all_articles)
         ]
 
-    @staticmethod
-    def get_main_article(soup):
+    @classmethod
+    def get_main_article(cls, soup):
         try:
             return FranceTvInfoFrontPage._get_highlighted_article(soup)
         except ValueError:

+ 4 - 4
src/media_observer/medias/le_figaro.py

@@ -7,14 +7,14 @@ from media_observer.article import (
 
 
 class LeFigaroFrontPage(FrontPage):
-    @staticmethod
-    def get_top_articles(soup: BeautifulSoup):
+    @classmethod
+    def get_top_articles(cls, soup: BeautifulSoup):
         # Le Figaro does not have such a view on its frontpage
 
         return []
 
-    @staticmethod
-    def get_main_article(soup):
+    @classmethod
+    def get_main_article(cls, soup):
         main = soup.select_first(".fig-main .fig-ensemble__first-article")
         url = main.select_first("a")
 

+ 4 - 4
src/media_observer/medias/le_monde.py

@@ -6,8 +6,8 @@ from media_observer.article import (
 
 
 class LeMondeFrontPage(FrontPage):
-    @staticmethod
-    def get_top_articles(soup):
+    @classmethod
+    def get_top_articles(cls, soup):
         all_articles = soup.select("div.top-article")
         return [
             TopArticle.create(
@@ -18,8 +18,8 @@ class LeMondeFrontPage(FrontPage):
             for idx, a in enumerate(all_articles)
         ]
 
-    @staticmethod
-    def get_main_article(soup):
+    @classmethod
+    def get_main_article(cls, soup):
         main = soup.select_unique("div.article--main")
         return MainArticle.create(
             title=main.select_unique("p.article__title-label").stripped_text,

+ 4 - 4
src/media_observer/medias/le_parisien.py

@@ -8,8 +8,8 @@ from media_observer.article import (
 
 
 class LeParisienFrontPage(FrontPage):
-    @staticmethod
-    def get_top_articles(soup: BeautifulSoup):
+    @classmethod
+    def get_top_articles(cls, soup: BeautifulSoup):
         all_articles = soup.select("a[data-block-name='Les_plus_lus']")
 
         return [
@@ -21,8 +21,8 @@ class LeParisienFrontPage(FrontPage):
             for idx, a in enumerate(all_articles)
         ]
 
-    @staticmethod
-    def get_main_article(soup):
+    @classmethod
+    def get_main_article(cls, soup):
         main = soup.select_first(".homepage__top article")
         url = main.select_first("a")
 

+ 4 - 4
src/media_observer/medias/tf1_info.py

@@ -8,8 +8,8 @@ from media_observer.article import (
 
 
 class Tf1InfoFrontPage(FrontPage):
-    @staticmethod
-    def get_top_articles(soup: BeautifulSoup):
+    @classmethod
+    def get_top_articles(cls, soup: BeautifulSoup):
         all_articles = soup.select("#AllNews__List__0 .AllNewsItem .LinkArticle")
 
         return [
@@ -26,8 +26,8 @@ class Tf1InfoFrontPage(FrontPage):
             rank=idx + 1,
         )
 
-    @staticmethod
-    def get_main_article(soup):
+    @classmethod
+    def get_main_article(cls, soup):
         main = soup.select_first("#headlineid .ArticleCard__Title")
         url = main.select_unique("a")