Changeset View
Changeset View
Standalone View
Standalone View
swh/deposit/cli/client.py
Show First 20 Lines • Show All 121 Lines • ▼ Show 20 Lines | ) -> str: | |||||||||||||
} | } | |||||||||||||
if external_id: | if external_id: | |||||||||||||
document["atom:entry"]["codemeta:identifier"] = external_id | document["atom:entry"]["codemeta:identifier"] = external_id | |||||||||||||
if create_origin: | if create_origin: | |||||||||||||
document["atom:entry"][ | document["atom:entry"][ | |||||||||||||
"@xmlns:swh" | "@xmlns:swh" | |||||||||||||
] = "https://www.softwareheritage.org/schema/2018/deposit" | ] = "https://www.softwareheritage.org/schema/2018/deposit" | |||||||||||||
document["atom:entry"]["swh:create_origin"] = { | document["atom:entry"]["swh:deposit"] = { | |||||||||||||
"swh:origin": {"@url": create_origin} | "swh:create_origin": {"swh:origin": {"@url": create_origin}} | |||||||||||||
ardumont: Found a bug!
it's missing the ['swh:deposit'] level. | ||||||||||||||
} | } | |||||||||||||
logging.debug("Atom entry dict to generate as xml: %s", document) | logging.debug("Atom entry dict to generate as xml: %s", document) | |||||||||||||
return xmltodict.unparse(document, pretty=True) | return xmltodict.unparse(document, pretty=True) | |||||||||||||
def _collection(client: PublicApiDepositClient) -> str: | def _collection(client: PublicApiDepositClient) -> str: | |||||||||||||
"""Retrieve the client's collection | """Retrieve the client's collection | |||||||||||||
▲ Show 20 Lines • Show All 106 Lines • ▼ Show 20 Lines | elif name or authors or create_origin: | |||||||||||||
"metadata file)." | "metadata file)." | |||||||||||||
) | ) | |||||||||||||
if not archive and not metadata: | if not archive and not metadata: | |||||||||||||
raise InputError( | raise InputError( | |||||||||||||
"Please provide an actionable command. See --help for more information" | "Please provide an actionable command. See --help for more information" | |||||||||||||
) | ) | |||||||||||||
if metadata: | ||||||||||||||
from swh.deposit.utils import parse_xml | ||||||||||||||
metadata_raw = open(metadata, "r").read() | ||||||||||||||
metadata_dict = parse_xml(metadata_raw).get("swh:deposit", {}) | ||||||||||||||
if ( | ||||||||||||||
"swh:create_origin" not in metadata_dict | ||||||||||||||
and "swh:add_to_origin" not in metadata_dict | ||||||||||||||
): | ||||||||||||||
logger.warning( | ||||||||||||||
"The metadata file provided should contain " | ||||||||||||||
'"<swh:create_origin>" or "<swh:add_to_origin>" tag', | ||||||||||||||
Done Inline Actions
vlorentz: | ||||||||||||||
) | ||||||||||||||
if replace and not deposit_id: | if replace and not deposit_id: | |||||||||||||
raise InputError("To update an existing deposit, you must provide its id") | raise InputError("To update an existing deposit, you must provide its id") | |||||||||||||
if not collection: | if not collection: | |||||||||||||
collection = _collection(client) | collection = _collection(client) | |||||||||||||
return { | return { | |||||||||||||
"archive": archive, | "archive": archive, | |||||||||||||
▲ Show 20 Lines • Show All 297 Lines • Show Last 20 Lines |
Found a bug!
it's missing the ['swh:deposit'] level.