From 04ca3186803ec3e232349a24a807f75aef3e6182 Mon Sep 17 00:00:00 2001 From: "Antoine R. Dumont (@ardumont)" Date: Sat, 5 Oct 2019 16:49:37 +0200 Subject: [PATCH] simple_lister: Extract common behavior in base class --- swh/lister/core/simple_lister.py | 6 ++++++ swh/lister/cran/lister.py | 6 ------ swh/lister/gnu/lister.py | 6 ------ swh/lister/packagist/lister.py | 6 ------ swh/lister/pypi/lister.py | 6 ------ 5 files changed, 6 insertions(+), 24 deletions(-) diff --git a/swh/lister/core/simple_lister.py b/swh/lister/core/simple_lister.py index 72f5b97..c31f4b7 100644 --- a/swh/lister/core/simple_lister.py +++ b/swh/lister/core/simple_lister.py @@ -59,6 +59,12 @@ class SimpleLister(ListerBase): return response, all_injected + def transport_response_simplified(self, response): + """Transform response to list for model manipulation + + """ + return [self.get_model_from_repo(repo_name) for repo_name in response] + def run(self): """Query the server which answers in one query. Stores the information, dropping actual redundant information we diff --git a/swh/lister/cran/lister.py b/swh/lister/cran/lister.py index 2c21852..414e833 100644 --- a/swh/lister/cran/lister.py +++ b/swh/lister/cran/lister.py @@ -93,9 +93,3 @@ class CRANLister(SimpleLister): 'origin_url': project_url, 'origin_type': 'cran', } - - def transport_response_simplified(self, response): - """Transform response to list for model manipulation - - """ - return [self.get_model_from_repo(repo) for repo in response] diff --git a/swh/lister/gnu/lister.py b/swh/lister/gnu/lister.py index 11daa2f..8609895 100644 --- a/swh/lister/gnu/lister.py +++ b/swh/lister/gnu/lister.py @@ -129,12 +129,6 @@ class GNULister(SimpleLister): 'origin_type': 'tar', } - def transport_response_simplified(self, response): - """Transform response to list for model manipulation - - """ - return [self.get_model_from_repo(repo) for repo in response] - def find_tarballs(package_file_structure, url): '''Recursively lists tarballs present in the folder and subfolders for a diff --git a/swh/lister/packagist/lister.py b/swh/lister/packagist/lister.py index c159ca6..1620e24 100644 --- a/swh/lister/packagist/lister.py +++ b/swh/lister/packagist/lister.py @@ -77,9 +77,3 @@ class PackagistLister(ListerOnePageApiTransport, SimpleLister): 'origin_url': url, 'origin_type': 'packagist', } - - def transport_response_simplified(self, response): - """Transform response to list for model manipulation - - """ - return [self.get_model_from_repo(repo_name) for repo_name in response] diff --git a/swh/lister/pypi/lister.py b/swh/lister/pypi/lister.py index c8e0e0d..4da6e55 100644 --- a/swh/lister/pypi/lister.py +++ b/swh/lister/pypi/lister.py @@ -68,9 +68,3 @@ class PyPILister(ListerOnePageApiTransport, SimpleLister): 'origin_url': project_url, 'origin_type': 'pypi', } - - def transport_response_simplified(self, response): - """(Override) Transform response to list for model manipulation - - """ - return [self.get_model_from_repo(repo_name) for repo_name in response]