Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
events-wrangler
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
VALLET Nathan
events-wrangler
Commits
44c6d743
Commit
44c6d743
authored
1 year ago
by
VALLET Nathan
Browse files
Options
Downloads
Patches
Plain Diff
add charge_urls and fusion_flux
parent
b9c53864
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
aggreg.py
+34
-0
34 additions, 0 deletions
aggreg.py
with
34 additions
and
0 deletions
aggreg.py
+
34
−
0
View file @
44c6d743
import
feedparser
from
urllib.parse
import
urlparse
from
datetime
import
datetime
def
charge_urls
(
liste_url
:
list
[
str
])
->
list
[
dict
[
str
,
any
]
|
None
]:
# if the key 'bozo' is true, then the feed had an error during processing, so we set it to None
return
[
feed
if
not
(
feed
:
=
feedparser
.
parse
(
url
))[
'
bozo
'
]
else
None
for
url
in
liste_url
]
def
fusion_flux
(
liste_url
:
list
[
str
],
liste_flux
:
list
[
dict
[
str
,
any
]
|
None
],
tri_chrono
:
bool
)
->
list
[
dict
[
str
,
str
]]:
feeds
=
[{
'
titre
'
:
entry
[
'
title
'
],
'
categorie
'
:
entry
[
'
category
'
],
'
serveur
'
:
urlparse
(
entry
[
'
title_detail
'
][
'
base
'
]).
netloc
,
'
date_publi
'
:
entry
[
'
published
'
],
'
lien
'
:
entry
[
'
link
'
],
'
description
'
:
entry
[
'
description
'
]
}
for
feed
in
liste_flux
for
entry
in
feed
[
'
entries
'
]]
if
tri_chrono
:
feeds
.
sort
(
key
=
lambda
e
:
datetime
.
strptime
(
e
[
'
date_publi
'
],
"
%a, %d %b %Y %H:%M
"
),
reverse
=
True
)
else
:
feeds
.
sort
(
key
=
lambda
e
:
[
"
CRITICAL
"
,
"
MAJOR
"
,
"
MINOR
"
].
index
(
e
[
'
categorie
'
]))
return
feeds
def
main
():
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment