Changeset View
Changeset View
Standalone View
Standalone View
swh/deposit/cli/client.py
Show First 20 Lines • Show All 172 Lines • ▼ Show 20 Lines | def client_command_parse_input( | ||||
if archive_deposit and metadata_deposit: | if archive_deposit and metadata_deposit: | ||||
# too many flags use, remove redundant ones (-> multipart deposit) | # too many flags use, remove redundant ones (-> multipart deposit) | ||||
archive_deposit = False | archive_deposit = False | ||||
metadata_deposit = False | metadata_deposit = False | ||||
if not slug: # generate one as this is mandatory | if not slug: # generate one as this is mandatory | ||||
slug = generate_slug() | slug = generate_slug() | ||||
if not metadata and name and authors: | if not metadata: | ||||
if name and authors: | |||||
metadata = generate_metadata_file(name, slug, authors, temp_dir) | metadata = generate_metadata_file(name, slug, authors, temp_dir) | ||||
elif not archive_deposit and not partial and not deposit_id: | |||||
# If we meet all the following conditions: | |||||
# * there is not an archive-only deposit | |||||
# * it is not part of a multipart deposit (either create/update | |||||
# or finish) | |||||
# * it misses either name or authors | |||||
raise InputError( | |||||
"Either a metadata file (--metadata) or both --author and " | |||||
"--name must be provided, unless this is an archive-only " | |||||
"deposit.") | |||||
elif name or authors: | |||||
# If we are generating metadata, then all mandatory metadata | |||||
# must be present | |||||
raise InputError( | |||||
"Either a metadata file (--metadata) or both --author and " | |||||
"--name must be provided.") | |||||
else: | |||||
# TODO: this is a multipart deposit, we might want to check that | |||||
# metadata are deposited at some point | |||||
pass | |||||
elif name or authors: | |||||
raise InputError( | |||||
"Using a metadata file (--metadata) is incompatible with " | |||||
ardumont: We could be lenient and drop the unneeded information.
By introspecting both metadata and flags… | |||||
Done Inline Actions
That's already what I'm doing. But if the user is giving contradictory arguments, you can't tell which way they should correct it. vlorentz: > By introspecting both metadata and flags then trying to determine what could be dropped. | |||||
"--author and --name, which are used to generate one.") | |||||
if metadata_deposit: | if metadata_deposit: | ||||
archive = None | archive = None | ||||
if archive_deposit: | if archive_deposit: | ||||
metadata = None | metadata = None | ||||
if metadata_deposit and not metadata: | if metadata_deposit and not metadata: | ||||
▲ Show 20 Lines • Show All 166 Lines • Show Last 20 Lines |
We could be lenient and drop the unneeded information.
By introspecting both metadata and flags then trying to determine what could be dropped.
In case of too much corner case and thus conflict, then raising and error to ask the clients what they really want ;)
That's a lot more work though...