swh.deposit.cli.client module

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

Bases: ValueError

Input script error


Trap and report exceptions (InputError, MaintenanceError) in a unified way.

swh.deposit.cli.client.generate_metadata(deposit_client: str, name: str, authors: List[str], external_id: Optional[str] = None, create_origin: Optional[str] = None, metadata_provenance_url: Optional[str] = None) str[source]

Generate sword compliant xml metadata with the minimum required metadata.

The Atom spec, https://tools.ietf.org/html/rfc4287, says that:

  • atom:entry elements MUST contain one or more atom:author elements

  • atom:entry elements MUST contain exactly one atom:title element.

  • atom:entry elements MUST contain exactly one atom:updated element.

However, we are also using CodeMeta, so we want some basic information to be mandatory.

Therefore, we generate the following mandatory fields:

  • deposit_client – Deposit client username,

  • name – Software name

  • authors – List of author names

  • create_origin – Origin concerned by the deposit

  • metadata_provenance_url – Provenance metadata url


metadata xml string

swh.deposit.cli.client.client_command_parse_input(client, username: str, archive: Optional[str], metadata: Optional[str], collection: Optional[str], slug: Optional[str], create_origin: Optional[str], metadata_provenance_url: Optional[str], partial: bool, deposit_id: Optional[int], swhid: Optional[str], replace: bool, url: str, name: Optional[str], authors: List[str], temp_dir: str) Dict[str, Any][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.

  • InputError explaining the user input related issue

  • MaintenanceError explaining the api status


“archive”: the software archive to deposit “username”: username “metadata”: the metadata file to deposit “collection”: the user’s collection under which to put the deposit “create_origin”: the origin concerned by the deposit “metadata_provenance_url”: the metadata provenance url “in_progress”: if the deposit is partial or not “url”: deposit’s server main entry point “deposit_id”: optional deposit identifier “swhid”: optional deposit swhid “replace”: whether the given deposit is to be replaced or not

Return type

dict with the following keys


Add default –url, –username and –password flag to cli.


Add –format output flag decorator to cli.

swh.deposit.cli.client.print_result(data: Dict[str, Any], output_format: Optional[str]) None[source]

Display the result data into a dedicated output format.