Changeset View
Changeset View
Standalone View
Standalone View
swh/lister/cli.py
# Copyright (C) 2018 The Software Heritage developers | # Copyright (C) 2018 The Software Heritage developers | ||||
# See the AUTHORS file at the top-level directory of this distribution | # See the AUTHORS file at the top-level directory of this distribution | ||||
# License: GNU General Public License version 3, or any later version | # License: GNU General Public License version 3, or any later version | ||||
# See top-level LICENSE file for more information | # See top-level LICENSE file for more information | ||||
import logging | import logging | ||||
import click | import click | ||||
from swh.core.cli import CONTEXT_SETTINGS | from swh.core.cli import CONTEXT_SETTINGS | ||||
logger = logging.getLogger(__name__) | logger = logging.getLogger(__name__) | ||||
SUPPORTED_LISTERS = ['github', 'gitlab', 'bitbucket', 'debian', 'pypi', | SUPPORTED_LISTERS = ['github', 'gitlab', 'bitbucket', 'debian', 'pypi', | ||||
'npm', 'phabricator', 'gnu', 'cran'] | 'npm', 'phabricator', 'gnu', 'cran', 'cgit'] | ||||
@click.group(name='lister', context_settings=CONTEXT_SETTINGS) | @click.group(name='lister', context_settings=CONTEXT_SETTINGS) | ||||
@click.pass_context | @click.pass_context | ||||
def lister(ctx): | def lister(ctx): | ||||
'''Software Heritage Lister tools.''' | '''Software Heritage Lister tools.''' | ||||
pass | pass | ||||
▲ Show 20 Lines • Show All 96 Lines • ▼ Show 20 Lines | for lister in listers: | ||||
from .gnu.lister import GNULister | from .gnu.lister import GNULister | ||||
_lister = GNULister(override_config=override_conf) | _lister = GNULister(override_config=override_conf) | ||||
elif lister == 'cran': | elif lister == '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 == 'cgit': | |||||
from .cgit.models import ModelBase | |||||
from .cgit.lister import CGitLister | |||||
_lister = CGitLister( | |||||
url='http://git.savannah.gnu.org/cgit/', | |||||
url_prefix='http://git.savannah.gnu.org/git/', | |||||
override_config=override_conf) | |||||
else: | else: | ||||
raise ValueError( | raise ValueError( | ||||
'Invalid lister %s: only supported listers are %s' % | 'Invalid lister %s: only supported listers are %s' % | ||||
(lister, SUPPORTED_LISTERS)) | (lister, SUPPORTED_LISTERS)) | ||||
if drop_tables: | if drop_tables: | ||||
logger.info('Dropping tables for %s', lister) | logger.info('Dropping tables for %s', lister) | ||||
ModelBase.metadata.drop_all(_lister.db_engine) | ModelBase.metadata.drop_all(_lister.db_engine) | ||||
Show All 15 Lines |