swh.deposit.cli.client module¶
-
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, external_id: Optional[str], authors: List[str]) → 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: - http://www.w3.org/2005/Atom#updated - http://www.w3.org/2005/Atom#author - http://www.w3.org/2005/Atom#title - 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
external_id – External identifier (slug) or generated one
authors – List of author names
- Returns
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], 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.
- 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 “slug”: the slug or external id identifying the deposit to make “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.