swh.deposit.cli.client module#
- exception swh.deposit.cli.client.InputError[source]#
Bases:
ValueError
Input script error
- swh.deposit.cli.client.trap_and_report_exceptions()[source]#
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: str | None = None, create_origin: str | None = None, metadata_provenance_url: str | None = 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:
https://doi.org/10.5063/SCHEMA/CODEMETA-2.0#name (yes, in addition to http://www.w3.org/2005/Atom#title, even if they have somewhat the same meaning)
- Parameters:
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
- Returns:
metadata xml string
- swh.deposit.cli.client.client_command_parse_input(client, username: str, archive: str | None, metadata: str | None, collection: str | None, slug: str | None, create_origin: str | None, metadata_provenance_url: str | None, partial: bool, deposit_id: int | None, swhid: str | None, replace: bool, url: str, name: str | None, 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.
- Raises:
InputError explaining the user input related issue –
MaintenanceError explaining the api status –
- Returns:
“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
- swh.deposit.cli.client.credentials_decorator(f)[source]#
Add default –url, –username and –password flag to cli.