Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
swh-graph
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Antoine Lambert
swh-graph
Commits
49986f16
Commit
49986f16
authored
4 months ago
by
Aymeric Varasse
Browse files
Options
Downloads
Patches
Plain Diff
Add checks to verify if provided SWHID is valid
parent
8ba7aab1
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
swh/graph/find_context.py
+10
-1
10 additions, 1 deletion
swh/graph/find_context.py
with
10 additions
and
1 deletion
swh/graph/find_context.py
+
10
−
1
View file @
49986f16
...
...
@@ -16,9 +16,10 @@ from swh.graph.grpc.swhgraph_pb2 import (
)
from
swh.graph.grpc.swhgraph_pb2_grpc
import
TraversalServiceStub
from
swh.model.cli
import
swhid_of_file
from
swh.model.exceptions
import
ValidationError
# documentation: https://docs.softwareheritage.org/devel/apidoc/swh.model.swhids.html
from
swh.model.swhids
import
ExtendedObjectType
,
ExtendedSWHID
from
swh.model.swhids
import
CoreSWHID
,
ExtendedObjectType
,
ExtendedSWHID
from
swh.web.client.client
import
WebAPIClient
# global variable holding headers parameters
...
...
@@ -121,6 +122,14 @@ def main(
global
swhcli
global
verbose
verbose
=
trace
# Check if content SWHID is valid
try
:
CoreSWHID
.
from_string
(
content_swhid
)
except
ValidationError
:
print
(
f
"
Error:
'
{
content_swhid
}
'
is not a valid SWHID
"
)
return
if
swh_bearer_token
:
swhcli
=
WebAPIClient
(
api_url
=
"
https://archive.softwareheritage.org/api/1/
"
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment