Skip to content
Snippets Groups Projects
Verified Commit 3f3f714c authored by Antoine R. Dumont's avatar Antoine R. Dumont
Browse files

cran.lister: Move helper function to the bottom of the file

parent 5b652b30
No related branches found
No related tags found
No related merge requests found
# 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)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment