Commit 9e556584 authored by shadMod's avatar shadMod 💬

reformat news.utils

parent 4757d859
Pipeline #361 failed with stage
in 0 seconds
......@@ -104,7 +104,7 @@ class GetNews:
fn.write(json.dumps(data))
@property
def index_news(self) -> list[dict]:
def index_news(self) -> list:
"""
Property to get indexes.json
"""
......@@ -114,7 +114,7 @@ class GetNews:
return self._index_news
@property
def category(self) -> list[str]:
def category(self) -> list:
"""
Property to get all category
"""
......@@ -123,7 +123,7 @@ class GetNews:
return self._category
@property
def years(self) -> list[str]:
def years(self) -> list:
"""
Property to get all years
"""
......@@ -132,7 +132,7 @@ class GetNews:
return self._year
@property
def list_year_month(self) -> list[str]:
def list_year_month(self) -> list:
data = []
for val in self.index_news:
year_month = f"{val['month']} {val['year']}"
......@@ -158,12 +158,12 @@ class GetNews:
return _birth_time, _last_edit
@staticmethod
def clean_html(value: str, html_tag: str):
def clean_html(value: str, html_tag: str) -> str:
for _vl in ["", "/"]:
value = value.replace(f"<{_vl}{html_tag}>", "")
return value
def get_list_data(self, key: str) -> list[str]:
def get_list_data(self, key: str) -> list:
data = []
for val in self.index_news:
if val[key] not in data:
......@@ -191,7 +191,7 @@ class GetNews:
raw = list(filter(lambda d: d['nr_file'] == nr_file, 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)
......@@ -295,13 +295,13 @@ class GetNews:
data["html"] = "".join(html_tmp)
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
:param counter: counter
:return: a list of news
:rtype: list[dict]
:rtype: list
"""
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