Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
swh-lister
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Platform
Development
swh-lister
Commits
af04129d
Verified
Commit
af04129d
authored
5 years ago
by
Antoine R. Dumont
Browse files
Options
Downloads
Patches
Plain Diff
lister.pypi: Align lister with pypi package loader
parent
6534df41
No related branches found
Branches containing commit
Tags
v2.6.2
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
swh/lister/pypi/lister.py
+8
-14
8 additions, 14 deletions
swh/lister/pypi/lister.py
swh/lister/pypi/tests/test_lister.py
+5
-7
5 additions, 7 deletions
swh/lister/pypi/tests/test_lister.py
with
13 additions
and
21 deletions
swh/lister/pypi/lister.py
+
8
−
14
View file @
af04129d
...
...
@@ -32,11 +32,8 @@ class PyPILister(ListerOnePageApiTransport, SimpleLister):
"""
_type
=
'
load-%s
'
%
origin_type
_policy
=
kwargs
.
get
(
'
policy
'
,
'
recurring
'
)
project_name
=
kwargs
.
get
(
'
name
'
)
project_metadata_url
=
kwargs
.
get
(
'
html_url
'
)
return
utils
.
create_task_dict
(
_type
,
_policy
,
project_name
,
origin_url
,
project_metadata_url
=
project_metadata_url
)
_type
,
_policy
,
url
=
origin_url
)
def
list_packages
(
self
,
response
):
"""
(Override) List the actual pypi origins from the response.
...
...
@@ -47,25 +44,22 @@ class PyPILister(ListerOnePageApiTransport, SimpleLister):
random
.
shuffle
(
_packages
)
return
_packages
def
_compute
_url
s
(
self
,
repo_name
)
:
"""
Returns
a tuple (project_url, project_metadata
_url
)
def
origin
_url
(
self
,
repo_name
:
str
)
->
str
:
"""
Returns
origin
_url
"""
return
(
'
https://pypi.org/project/%s/
'
%
repo_name
,
'
https://pypi.org/pypi/%s/json
'
%
repo_name
)
return
'
https://pypi.org/project/%s/
'
%
repo_name
def
get_model_from_repo
(
self
,
repo_name
):
"""
(Override) Transform from repository representation to model
"""
project_url
,
project_url_meta
=
self
.
_compute
_url
s
(
repo_name
)
origin_url
=
self
.
origin
_url
(
repo_name
)
return
{
'
uid
'
:
repo_name
,
'
uid
'
:
origin_url
,
'
name
'
:
repo_name
,
'
full_name
'
:
repo_name
,
'
html_url
'
:
project_url_meta
,
'
origin_url
'
:
project
_url
,
'
html_url
'
:
origin_url
,
'
origin_url
'
:
origin
_url
,
'
origin_type
'
:
'
pypi
'
,
}
This diff is collapsed.
Click to expand it.
swh/lister/pypi/tests/test_lister.py
+
5
−
7
View file @
af04129d
...
...
@@ -14,16 +14,14 @@ def test_pypi_lister(lister_pypi, requests_mock_datadir):
assert
row
[
'
type
'
]
==
'
load-pypi
'
# arguments check
args
=
row
[
'
arguments
'
][
'
args
'
]
assert
len
(
args
)
==
2
project
=
args
[
0
]
url
=
args
[
1
]
assert
url
==
'
https://pypi.org/project/%s/
'
%
project
assert
len
(
args
)
==
0
# kwargs
kwargs
=
row
[
'
arguments
'
][
'
kwargs
'
]
meta_url
=
kwargs
[
'
project_metadata_url
'
]
assert
meta_url
==
'
https://pypi.org/pypi/%s/json
'
%
project
assert
len
(
kwargs
)
==
1
origin_url
=
kwargs
[
'
url
'
]
assert
'
https://pypi.org/project
'
in
origin_url
assert
row
[
'
policy
'
]
==
'
recurring
'
assert
row
[
'
priority
'
]
is
None
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