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
02b48162
Commit
02b48162
authored
Nov 04, 2023
by
shadMod
💬
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rename row_list() with get_table_rows() to get all table rows
now get_list_version() return sort list
parent
b1eee15e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
19 deletions
+27
-19
uitwww/src/download/compile_download.py
uitwww/src/download/compile_download.py
+27
-19
No files found.
uitwww/src/download/compile_download.py
View file @
02b48162
...
...
@@ -28,8 +28,11 @@ class UbuntuRelease:
self
.
ignore_lts
=
ignore_lts
self
.
ignore_interim
=
ignore_interim
@
property
def
row_list
(
self
)
->
list
:
def
get_table_rows
(
self
,
only_data
:
bool
=
True
):
"""
:param only_data: to check you want to ignore the table header
"""
# get requests
res
=
requests
.
get
(
self
.
path_url
)
# check requests status code
...
...
@@ -38,37 +41,42 @@ class UbuntuRelease:
raise
Exception
(
f"Error requests - status:
{
status
}
"
)
# get all table rows
table_rows
=
html
.
fromstring
(
res
.
content
).
xpath
(
'//pre//text()'
)
# if only_data is True ignore table header
if
only_data
is
True
:
return
table_rows
[
8
:]
# else get all table
return
table_rows
@
property
def
get_list_version
(
self
)
->
list
:
# init clean row and row_list
row
=
[]
row_list
=
[]
# get table_rows without header
for
val
in
table_rows
[
8
:]
:
for
val
in
self
.
get_table_rows
()
:
val
=
val
.
strip
()
if
val
:
if
'Ubuntu '
not
in
val
:
row
.
append
(
val
.
replace
(
"/"
,
""
))
else
:
row
.
append
(
val
)
row_list
.
append
(
row
)
row
=
[]
return
row_list
@
property
def
get_list_version
(
self
)
->
dict
:
data
=
{
"latest"
:
[],
"lts"
:
[]}
for
row
in
self
.
row_list
:
if
not
row
[
0
].
split
(
"."
)[
0
].
isnumeric
():
continue
if
'LTS'
in
row
[
1
]:
name
=
row
[
1
].
split
(
"("
)[
1
].
replace
(
")"
,
""
)
short
=
name
.
split
()[
0
].
lower
()
data
[
'lts'
].
append
((
row
[
0
],
short
,
name
))
else
:
if
len
(
row
)
==
2
:
if
not
row
[
0
].
split
(
"."
)[
0
].
isnumeric
():
continue
if
'LTS'
in
row
[
1
]:
typology
=
"LTS"
else
:
typology
=
"interim"
name
=
row
[
1
].
split
(
"("
)[
1
].
replace
(
")"
,
""
)
short
=
name
.
split
()[
0
].
lower
()
data
[
'latest'
].
append
((
row
[
0
],
short
,
name
))
return
data
row_list
.
append
((
row
[
0
],
short
,
name
,
typology
))
row
=
[]
# the lambda is just out of scruple
return
sorted
(
row_list
,
key
=
lambda
x
:
x
[
0
],
reverse
=
True
)
class
CompileVersion
:
...
...
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