swh.deposit.cli.client module

exception swh.deposit.cli.client.InputError[source]

Bases: ValueError

Input script error

swh.deposit.cli.client.generate_slug()[source]

Generate a slug (sample purposes).

swh.deposit.cli.client.generate_metadata_file(name, external_id, authors, temp_dir)[source]

Generate a temporary metadata file with the minimum required metadata

This generates a xml file in a temporary location and returns the path to that file.

This is up to the client of that function to clean up the temporary file.

Parameters
  • name (str) – Software’s name

  • external_id (str) – External identifier (slug) or generated one

  • authors (List[str]) – List of author names

Returns

Filepath to the metadata generated file

swh.deposit.cli.client.client_command_parse_input(username, password, archive, metadata, archive_deposit, metadata_deposit, collection, slug, partial, deposit_id, replace, url, name, authors, temp_dir)[source]
Parse the client subcommand options and make sure the combination

is acceptable*. If not, an InputError exception is raised explaining the issue.

By acceptable, we mean:

  • A multipart deposit (create or update) requires:

    • an existing software archive

    • an existing metadata file or author(s) and name provided in params

  • A binary deposit (create/update) requires an existing software archive

  • A metadata deposit (create/update) requires an existing metadata file or author(s) and name provided in params

  • A deposit update requires a deposit_id

This will not prevent all failure cases though. The remaining errors are already dealt with by the underlying api client.

Raises
  • InputError explaining the user input related issue

  • MaintenanceError explaining the api status

Returns

‘archive’: the software archive to deposit ‘username’: username ‘password’: associated password ‘metadata’: the metadata file to deposit ‘collection’: the username’s associated client ‘slug’: the slug or external id identifying the deposit to make ‘partial’: if the deposit is partial or not ‘client’: instantiated class ‘url’: deposit’s server main entry point ‘deposit_type’: deposit’s type (binary, multipart, metadata) ‘deposit_id’: optional deposit identifier

Return type

dict with the following keys

swh.deposit.cli.client.deposit_create(config, logger)[source]

Delegate the actual deposit to the deposit client.

swh.deposit.cli.client.deposit_update(config, logger)[source]

Delegate the actual deposit to the deposit client.

swh.deposit.cli.client.print_result(data, output_format)[source]