Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
swh-model
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
Model registry
Operate
Environments
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
Platform
Development
swh-model
Commits
02d0898d
Commit
02d0898d
authored
7 months ago
by
Hélène Jonin
Browse files
Options
Downloads
Patches
Plain Diff
CoreSWHID: add to_qualified method
parent
85b58be1
No related branches found
Branches containing commit
Tags
v6.16.0
Tags containing commit
1 merge request
!365
CoreSWHID: add to_qualified method
Pipeline
#11090
passed
3 months ago
Stage: external
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
swh/model/swhids.py
+11
-0
11 additions, 0 deletions
swh/model/swhids.py
swh/model/tests/test_swhids.py
+12
-0
12 additions, 0 deletions
swh/model/tests/test_swhids.py
with
23 additions
and
0 deletions
swh/model/swhids.py
+
11
−
0
View file @
02d0898d
...
...
@@ -197,6 +197,17 @@ class CoreSWHID(_BaseSWHID[ObjectType]):
object_id
=
self
.
object_id
,
)
def
to_qualified
(
self
)
->
QualifiedSWHID
:
"""
Converts this CoreSWHID into a QualifiedSWHID.
As QualifiedSWHID is a superset of CoreSWHID, this is lossless.
"""
return
QualifiedSWHID
(
namespace
=
self
.
namespace
,
scheme_version
=
self
.
scheme_version
,
object_type
=
self
.
object_type
,
object_id
=
self
.
object_id
,
)
def
_parse_core_swhid
(
swhid
:
Union
[
str
,
CoreSWHID
,
None
])
->
Optional
[
CoreSWHID
]:
if
swhid
is
None
or
isinstance
(
swhid
,
CoreSWHID
):
...
...
This diff is collapsed.
Click to expand it.
swh/model/tests/test_swhids.py
+
12
−
0
View file @
02d0898d
...
...
@@ -257,6 +257,18 @@ def test_core_to_extended(core, extended):
assert
core
.
to_extended
()
==
extended
@pytest.mark.parametrize
(
"
core,qualified
"
,
[
pytest
.
param
(
core
,
qualified
,
id
=
string
)
for
(
string
,
core
,
qualified
,
extended
)
in
VALID_SWHIDS
if
core
is
not
None
],
)
def
test_core_to_qualified
(
core
,
qualified
):
assert
core
.
to_qualified
()
==
qualified
@pytest.mark.parametrize
(
"
ns,version,type,id,qualifiers
"
,
[
...
...
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