Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F7163837
D421.id.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Subscribers
None
D421.id.diff
View Options
diff --git a/swh/loader/pypi/client.py b/swh/loader/pypi/client.py
--- a/swh/loader/pypi/client.py
+++ b/swh/loader/pypi/client.py
@@ -3,6 +3,7 @@
# License: GNU General Public License version 3, or any later version
# See top-level LICENSE file for more information
+from collections import defaultdict
import logging
import os
import shutil
@@ -410,6 +411,16 @@
logging.debug('Clean up archive %s' % archive_path)
os.unlink(archive_path)
+ def all_release_artifacts(self):
+ """Generate a mapping of releases to their artifacts"""
+ ret = defaultdict(list)
+ for version, artifacts in self.data['releases'].items():
+ for artifact in self._filter_release_artifacts(version, artifacts):
+ ret[version].append((artifact['filename'],
+ artifact['digests']['sha256']))
+
+ return ret
+
def download_new_releases(self, known_artifacts):
"""Fetch metadata/data per release (if new release artifact detected)
diff --git a/swh/loader/pypi/tests/test_client.py b/swh/loader/pypi/tests/test_client.py
--- a/swh/loader/pypi/tests/test_client.py
+++ b/swh/loader/pypi/tests/test_client.py
@@ -15,7 +15,7 @@
class PyPIProjectTest(WithProjectTest):
@istest
- def releases(self):
+ def download_new_releases(self):
actual_releases = self.project.download_new_releases([])
expected_release_artifacts = {
@@ -76,3 +76,23 @@
for dir_path in dir_paths:
# path no longer exists
self.assertFalse(os.path.exists(dir_path))
+
+ @istest
+ def all_release_artifacts(self):
+ expected_release_artifacts = {
+ '1.1.0': [(
+ '0805nexter-1.1.0.zip',
+ '52cd128ad3afe539478abc7440d4b043'
+ '384295fbe6b0958a237cb6d926465035',
+ )],
+ '1.2.0': [(
+ '0805nexter-1.2.0.zip',
+ '49785c6ae39ea511b3c253d7621c0b1b'
+ '6228be2f965aca8a491e6b84126d0709',
+ )],
+ }
+
+ self.assertEqual(
+ self.project.all_release_artifacts(),
+ expected_release_artifacts,
+ )
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Jan 30, 4:35 PM (2 h, 37 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3225581
Attached To
D421: Provide an all_release_artifacts endpoint to PyPIClient
Event Timeline
Log In to Comment