Commit 6e5458de authored by shadMod's avatar shadMod 💬

reformat news.utils

parent 6dd95370
...@@ -104,7 +104,7 @@ class GetNews: ...@@ -104,7 +104,7 @@ class GetNews:
fn.write(json.dumps(data)) fn.write(json.dumps(data))
@property @property
def index_news(self) -> list[dict]: def index_news(self) -> list:
""" """
Property to get indexes.json Property to get indexes.json
""" """
...@@ -114,7 +114,7 @@ class GetNews: ...@@ -114,7 +114,7 @@ class GetNews:
return self._index_news return self._index_news
@property @property
def category(self) -> list[str]: def category(self) -> list:
""" """
Property to get all category Property to get all category
""" """
...@@ -123,7 +123,7 @@ class GetNews: ...@@ -123,7 +123,7 @@ class GetNews:
return self._category return self._category
@property @property
def years(self) -> list[str]: def years(self) -> list:
""" """
Property to get all years Property to get all years
""" """
...@@ -132,7 +132,7 @@ class GetNews: ...@@ -132,7 +132,7 @@ class GetNews:
return self._year return self._year
@property @property
def list_year_month(self) -> list[str]: def list_year_month(self) -> list:
data = [] data = []
for val in self.index_news: for val in self.index_news:
year_month = f"{val['month']} {val['year']}" year_month = f"{val['month']} {val['year']}"
...@@ -158,12 +158,12 @@ class GetNews: ...@@ -158,12 +158,12 @@ class GetNews:
return _birth_time, _last_edit return _birth_time, _last_edit
@staticmethod @staticmethod
def clean_html(value: str, html_tag: str): def clean_html(value: str, html_tag: str) -> str:
for _vl in ["", "/"]: for _vl in ["", "/"]:
value = value.replace(f"<{_vl}{html_tag}>", "") value = value.replace(f"<{_vl}{html_tag}>", "")
return value return value
def get_list_data(self, key: str) -> list[str]: def get_list_data(self, key: str) -> list:
data = [] data = []
for val in self.index_news: for val in self.index_news:
if val[key] not in data: if val[key] not in data:
...@@ -191,7 +191,7 @@ class GetNews: ...@@ -191,7 +191,7 @@ class GetNews:
raw = list(filter(lambda d: d['nr_file'] == nr_file, raw)) raw = list(filter(lambda d: d['nr_file'] == nr_file, raw))
return raw return raw
def list_news(self, year: str, category: str, month: str = None) -> list[dict]: def list_news(self, year: str, category: str, month: str = None) -> list:
""" """
Method to get a list of news (with filters) Method to get a list of news (with filters)
...@@ -295,13 +295,13 @@ class GetNews: ...@@ -295,13 +295,13 @@ class GetNews:
data["html"] = "".join(html_tmp) data["html"] = "".join(html_tmp)
return data return data
def news_max(self, counter: int) -> list[dict]: def news_max(self, counter: int) -> list:
""" """
Method used on the Home Page to have a maximum number of items displayed Method used on the Home Page to have a maximum number of items displayed
:param counter: counter :param counter: counter
:return: a list of news :return: a list of news
:rtype: list[dict] :rtype: list
""" """
return self.index_news[:counter] return self.index_news[:counter]
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment