cran.lister: Move helper function to the bottom of the file
This commit is contained in:
parent
5b652b3070
commit
3f3f714c62
1 changed files with 26 additions and 26 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue