Changeset View
Changeset View
Standalone View
Standalone View
swh/deposit/cli/client.py
- This file was moved from swh/deposit/cli/deposit.py.
# Copyright (C) 2017-2019 The Software Heritage developers | # Copyright (C) 2017-2019 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 os | import os | ||||
import logging | import logging | ||||
import tempfile | import tempfile | ||||
import uuid | import uuid | ||||
import click | import click | ||||
import xmltodict | import xmltodict | ||||
from swh.deposit.client import PublicApiDepositClient | from swh.deposit.client import PublicApiDepositClient | ||||
from swh.deposit.cli import cli | from swh.deposit.cli import deposit | ||||
logger = logging.getLogger(__name__) | logger = logging.getLogger(__name__) | ||||
class InputError(ValueError): | class InputError(ValueError): | ||||
"""Input script error | """Input script error | ||||
▲ Show 20 Lines • Show All 237 Lines • ▼ Show 20 Lines | def deposit_update(config, logger): | ||||
client = config['client'] | client = config['client'] | ||||
keys = ('collection', 'deposit_id', 'archive', 'metadata', | keys = ('collection', 'deposit_id', 'archive', 'metadata', | ||||
'slug', 'in_progress', 'replace') | 'slug', 'in_progress', 'replace') | ||||
return client.deposit_update( | return client.deposit_update( | ||||
**_subdict(config, keys)) | **_subdict(config, keys)) | ||||
@cli.command() | @deposit.command() | ||||
@click.option('--username', required=1, | @click.option('--username', required=1, | ||||
help="(Mandatory) User's name") | help="(Mandatory) User's name") | ||||
@click.option('--password', required=1, | @click.option('--password', required=1, | ||||
help="(Mandatory) User's associated password") | help="(Mandatory) User's associated password") | ||||
@click.option('--archive', | @click.option('--archive', | ||||
help='(Optional) Software archive to deposit') | help='(Optional) Software archive to deposit') | ||||
@click.option('--metadata', | @click.option('--metadata', | ||||
help="(Optional) Path to xml metadata file. If not provided, this will use a file named <archive>.metadata.xml") # noqa | help="(Optional) Path to xml metadata file. If not provided, this will use a file named <archive>.metadata.xml") # noqa | ||||
Show All 18 Lines | |||||
@click.option('--verbose/--no-verbose', default=False, | @click.option('--verbose/--no-verbose', default=False, | ||||
help='Verbose mode') | help='Verbose mode') | ||||
@click.option('--name', | @click.option('--name', | ||||
help='Software name') | help='Software name') | ||||
@click.option('--author', multiple=True, | @click.option('--author', multiple=True, | ||||
help='Software author(s), this can be repeated as many times' | help='Software author(s), this can be repeated as many times' | ||||
' as there are authors') | ' as there are authors') | ||||
@click.pass_context | @click.pass_context | ||||
def deposit(ctx, | def upload(ctx, | ||||
username, password, archive=None, metadata=None, | username, password, archive=None, metadata=None, | ||||
archive_deposit=False, metadata_deposit=False, | archive_deposit=False, metadata_deposit=False, | ||||
collection=None, slug=None, partial=False, deposit_id=None, | collection=None, slug=None, partial=False, deposit_id=None, | ||||
replace=False, status=False, | replace=False, status=False, | ||||
url='https://deposit.softwareheritage.org/1', | url='https://deposit.softwareheritage.org/1', | ||||
verbose=False, name=None, author=None): | verbose=False, name=None, author=None): | ||||
"""Software Heritage Public Deposit Client | """Software Heritage Public Deposit Client | ||||
Create/Update deposit through the command line or access its | Create/Update deposit through the command line or access its | ||||
status. | status. | ||||
More documentation can be found at | More documentation can be found at | ||||
https://docs.softwareheritage.org/devel/swh-deposit/getting-started.html. | https://docs.softwareheritage.org/devel/swh-deposit/getting-started.html. | ||||
Show All 35 Lines |