From 3f3f714c62c29c0b83d0563c7f7c4711128c05f8 Mon Sep 17 00:00:00 2001 From: "Antoine R. Dumont (@ardumont)" Date: Mon, 6 Jan 2020 16:55:23 +0100 Subject: [PATCH] cran.lister: Move helper function to the bottom of the file --- swh/lister/cran/lister.py | 52 +++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/swh/lister/cran/lister.py b/swh/lister/cran/lister.py index bb11ae5..20d6dd6 100644 --- a/swh/lister/cran/lister.py +++ b/swh/lister/cran/lister.py @@ -1,4 +1,4 @@ -# Copyright (C) 2019 The Software Heritage developers +# Copyright (C) 2019-2020 The Software Heritage developers # See the AUTHORS file at the top-level directory of this distribution # License: GNU General Public License version 3, or any later version # See top-level LICENSE file for more information @@ -19,31 +19,6 @@ from swh.scheduler.utils import create_task_dict logger = logging.getLogger(__name__) -def read_cran_data() -> List[Mapping[str, str]]: - """Execute r script to read cran listing. - - """ - filepath = pkg_resources.resource_filename('swh.lister.cran', - 'list_all_packages.R') - logger.debug('script list-all-packages.R path: %s', filepath) - response = subprocess.run(filepath, stdout=subprocess.PIPE, shell=False) - return json.loads(response.stdout.decode('utf-8')) - - -def compute_package_url(repo: Mapping[str, str]) -> str: - """Compute the package url from the repo dict. - - Args: - repo: dict with key 'Package', 'Version' - - Returns: - the package url - - """ - return 'https://cran.r-project.org/src/contrib' \ - '/{Package}_{Version}.tar.gz'.format(**repo) - - class CRANLister(SimpleLister): MODEL = CRANModel LISTER_NAME = 'cran' @@ -130,3 +105,28 @@ class CRANLister(SimpleLister): 'origin_url': project_url, 'origin_type': 'tar', } + + +def read_cran_data() -> List[Mapping[str, str]]: + """Execute r script to read cran listing. + + """ + filepath = pkg_resources.resource_filename('swh.lister.cran', + 'list_all_packages.R') + logger.debug('script list-all-packages.R path: %s', filepath) + response = subprocess.run(filepath, stdout=subprocess.PIPE, shell=False) + return json.loads(response.stdout.decode('utf-8')) + + +def compute_package_url(repo: Mapping[str, str]) -> str: + """Compute the package url from the repo dict. + + Args: + repo: dict with key 'Package', 'Version' + + Returns: + the package url + + """ + return 'https://cran.r-project.org/src/contrib' \ + '/{Package}_{Version}.tar.gz'.format(**repo)