Changeset View
Changeset View
Standalone View
Standalone View
swh/lister/cli.py
Show All 13 Lines | |||||
SUPPORTED_LISTERS = ['github', 'gitlab', 'bitbucket', 'debian', 'pypi', | SUPPORTED_LISTERS = ['github', 'gitlab', 'bitbucket', 'debian', 'pypi', | ||||
'npm', 'phabricator', 'gnu', 'cran', 'cgit', 'packagist'] | 'npm', 'phabricator', 'gnu', 'cran', 'cgit', 'packagist'] | ||||
# Base urls for most listers | # Base urls for most listers | ||||
DEFAULT_BASEURLS = { | DEFAULT_BASEURLS = { | ||||
'gitlab': 'https://gitlab.com/api/v4/', | 'gitlab': 'https://gitlab.com/api/v4/', | ||||
'phabricator': 'https://forge.softwareheritage.org', | 'phabricator': 'https://forge.softwareheritage.org', | ||||
'cgit': ( | |||||
'http://git.savannah.gnu.org/cgit/', | |||||
'http://git.savannah.gnu.org/git/' | |||||
), | |||||
} | } | ||||
def get_lister(lister_name, db_url, drop_tables=False, **conf): | def get_lister(lister_name, db_url, drop_tables=False, **conf): | ||||
"""Instantiate a lister given its name. | """Instantiate a lister given its name. | ||||
Args: | Args: | ||||
lister_name (str): Lister's name | lister_name (str): Lister's name | ||||
▲ Show 20 Lines • Show All 93 Lines • ▼ Show 20 Lines | def get_lister(lister_name, db_url, drop_tables=False, **conf): | ||||
elif lister_name == 'cran': | elif lister_name == 'cran': | ||||
from .cran.models import ModelBase | from .cran.models import ModelBase | ||||
from .cran.lister import CRANLister | from .cran.lister import CRANLister | ||||
_lister = CRANLister(override_config=override_conf) | _lister = CRANLister(override_config=override_conf) | ||||
elif lister_name == 'cgit': | elif lister_name == 'cgit': | ||||
from .cgit.models import ModelBase | from .cgit.models import ModelBase | ||||
from .cgit.lister import CGitLister | from .cgit.lister import CGitLister | ||||
if isinstance(api_baseurl, str): | |||||
_lister = CGitLister(url=api_baseurl, | _lister = CGitLister(url=api_baseurl, | ||||
override_config=override_conf) | override_config=override_conf) | ||||
else: # tuple | |||||
_lister = CGitLister(url=api_baseurl[0], | |||||
url_prefix=api_baseurl[1], | |||||
override_config=override_conf) | |||||
elif lister_name == 'packagist': | elif lister_name == 'packagist': | ||||
from .packagist.models import ModelBase # noqa | from .packagist.models import ModelBase # noqa | ||||
from .packagist.lister import PackagistLister | from .packagist.lister import PackagistLister | ||||
_lister = PackagistLister(override_config=override_conf) | _lister = PackagistLister(override_config=override_conf) | ||||
else: | else: | ||||
raise ValueError( | raise ValueError( | ||||
▲ Show 20 Lines • Show All 88 Lines • Show Last 20 Lines |