Skip to content

Commit

Permalink
Simplify argument handling logic for readability
Browse files Browse the repository at this point in the history
  • Loading branch information
waxlamp committed Oct 3, 2024
1 parent b39cfb5 commit ccf08bf
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions dandiapi/api/management/commands/calculate_sha256.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@ def calculate_sha256(asset_id: str | None = None, blob_id: str | None = None):
Either blob-id or asset-id should be provided.
"""
# Handle mutually exclusive option failure cases.
if not asset_id and not blob_id:
raise ValueError('Provide either asset_id or blob_id')
if asset_id and blob_id:
raise ValueError('Provide only asset_id or blob_id, not both')

# Make sure we have a good blob_id to work with.
if asset_id:
if blob_id:
raise ValueError('Provide only asset_id or blob_id, not both')
asset = Asset.objects.get(asset_id=asset_id)
blob_id = asset.blob_id

Expand Down

0 comments on commit ccf08bf

Please sign in to comment.