Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
Nuovo sito
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
16
Issues
16
List
Boards
Labels
Milestones
Merge Requests
2
Merge Requests
2
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Gruppo Web
Nuovo sito
Commits
6e5458de
Commit
6e5458de
authored
Dec 27, 2023
by
shadMod
💬
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
reformat news.utils
parent
6dd95370
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
9 deletions
+9
-9
uitwww/src/news/utils.py
uitwww/src/news/utils.py
+9
-9
No files found.
uitwww/src/news/utils.py
View file @
6e5458de
...
...
@@ -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
]
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment