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
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
Jérémy Bobbio (Lunar)
swh-model
Commits
e0b4b946
Commit
e0b4b946
authored
4 years ago
by
Thibault Allançon
Browse files
Options
Downloads
Patches
Plain Diff
model: remove deprecated and unused PID methods
Use the new SWHID naming convention instead of SWH PID.
parent
a2737185
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
swh/model/identifiers.py
+0
-43
0 additions, 43 deletions
swh/model/identifiers.py
swh/model/model.py
+12
-12
12 additions, 12 deletions
swh/model/model.py
with
12 additions
and
55 deletions
swh/model/identifiers.py
+
0
−
43
View file @
e0b4b946
...
@@ -10,7 +10,6 @@ import hashlib
...
@@ -10,7 +10,6 @@ import hashlib
from
typing
import
Any
,
Dict
,
Union
from
typing
import
Any
,
Dict
,
Union
import
attr
import
attr
from
deprecated
import
deprecated
from
.collections
import
ImmutableDict
from
.collections
import
ImmutableDict
from
.exceptions
import
ValidationError
from
.exceptions
import
ValidationError
...
@@ -30,13 +29,6 @@ SWHID_TYPES = ["ori", "snp", "rel", "rev", "dir", "cnt"]
...
@@ -30,13 +29,6 @@ SWHID_TYPES = ["ori", "snp", "rel", "rev", "dir", "cnt"]
SWHID_SEP
=
"
:
"
SWHID_SEP
=
"
:
"
SWHID_CTXT_SEP
=
"
;
"
SWHID_CTXT_SEP
=
"
;
"
# deprecated variables
PID_NAMESPACE
=
SWHID_NAMESPACE
PID_VERSION
=
SWHID_VERSION
PID_TYPES
=
SWHID_TYPES
PID_SEP
=
SWHID_SEP
PID_CTXT_SEP
=
SWHID_CTXT_SEP
@lru_cache
()
@lru_cache
()
def
identifier_to_bytes
(
identifier
):
def
identifier_to_bytes
(
identifier
):
...
@@ -736,20 +728,6 @@ class SWHID:
...
@@ -736,20 +728,6 @@ class SWHID:
return
swhid
return
swhid
@deprecated
(
"
Use swh.model.identifiers.SWHID instead
"
)
class
PersistentId
(
SWHID
):
"""
Named tuple holding the relevant info associated to a SoftWare Heritage
persistent IDentifier.
.. deprecated:: 0.3.8
Use :class:`swh.model.identifiers.SWHID` instead
"""
pass
def
swhid
(
def
swhid
(
object_type
:
str
,
object_type
:
str
,
object_id
:
Union
[
str
,
Dict
[
str
,
Any
]],
object_id
:
Union
[
str
,
Dict
[
str
,
Any
]],
...
@@ -784,17 +762,6 @@ def swhid(
...
@@ -784,17 +762,6 @@ def swhid(
return
str
(
swhid
)
return
str
(
swhid
)
@deprecated
(
"
Use swh.model.identifiers.swhid instead
"
)
def
persistent_identifier
(
*
args
,
**
kwargs
)
->
str
:
"""
Compute :ref:`persistent-identifiers`
.. deprecated:: 0.3.8
Use :func:`swh.model.identifiers.swhid` instead
"""
return
swhid
(
*
args
,
**
kwargs
)
def
parse_swhid
(
swhid
:
str
)
->
SWHID
:
def
parse_swhid
(
swhid
:
str
)
->
SWHID
:
"""
Parse :ref:`persistent-identifiers`.
"""
Parse :ref:`persistent-identifiers`.
...
@@ -848,13 +815,3 @@ def parse_swhid(swhid: str) -> SWHID:
...
@@ -848,13 +815,3 @@ def parse_swhid(swhid: str) -> SWHID:
_id
,
_id
,
_metadata
,
# type: ignore # mypy can't properly unify types
_metadata
,
# type: ignore # mypy can't properly unify types
)
)
@deprecated
(
"
Use swh.model.identifiers.parse_swhid instead
"
)
def
parse_persistent_identifier
(
persistent_id
:
str
)
->
PersistentId
:
"""
Parse :ref:`persistent-identifiers`.
.. deprecated:: 0.3.8
Use :func:`swh.model.identifiers.parse_swhid` instead
"""
return
PersistentId
(
**
parse_swhid
(
persistent_id
).
to_dict
())
This diff is collapsed.
Click to expand it.
swh/model/model.py
+
12
−
12
View file @
e0b4b946
...
@@ -856,7 +856,7 @@ class RawExtrinsicMetadata(BaseModel):
...
@@ -856,7 +856,7 @@ class RawExtrinsicMetadata(BaseModel):
"
Got SWHID as id for origin metadata (expected an URL).
"
"
Got SWHID as id for origin metadata (expected an URL).
"
)
)
else
:
else
:
self
.
_check_
p
id
(
self
.
type
.
value
,
value
)
self
.
_check_
swh
id
(
self
.
type
.
value
,
value
)
@discovery_date.validator
@discovery_date.validator
def
check_discovery_date
(
self
,
attribute
,
value
):
def
check_discovery_date
(
self
,
attribute
,
value
):
...
@@ -925,7 +925,7 @@ class RawExtrinsicMetadata(BaseModel):
...
@@ -925,7 +925,7 @@ class RawExtrinsicMetadata(BaseModel):
f
"
Unexpected
'
snapshot
'
context for
{
self
.
type
.
value
}
object:
{
value
}
"
f
"
Unexpected
'
snapshot
'
context for
{
self
.
type
.
value
}
object:
{
value
}
"
)
)
self
.
_check_
p
id
(
"
snapshot
"
,
value
)
self
.
_check_
swh
id
(
"
snapshot
"
,
value
)
@release.validator
@release.validator
def
check_release
(
self
,
attribute
,
value
):
def
check_release
(
self
,
attribute
,
value
):
...
@@ -941,7 +941,7 @@ class RawExtrinsicMetadata(BaseModel):
...
@@ -941,7 +941,7 @@ class RawExtrinsicMetadata(BaseModel):
f
"
Unexpected
'
release
'
context for
{
self
.
type
.
value
}
object:
{
value
}
"
f
"
Unexpected
'
release
'
context for
{
self
.
type
.
value
}
object:
{
value
}
"
)
)
self
.
_check_
p
id
(
"
release
"
,
value
)
self
.
_check_
swh
id
(
"
release
"
,
value
)
@revision.validator
@revision.validator
def
check_revision
(
self
,
attribute
,
value
):
def
check_revision
(
self
,
attribute
,
value
):
...
@@ -953,7 +953,7 @@ class RawExtrinsicMetadata(BaseModel):
...
@@ -953,7 +953,7 @@ class RawExtrinsicMetadata(BaseModel):
f
"
Unexpected
'
revision
'
context for
{
self
.
type
.
value
}
object:
{
value
}
"
f
"
Unexpected
'
revision
'
context for
{
self
.
type
.
value
}
object:
{
value
}
"
)
)
self
.
_check_
p
id
(
"
revision
"
,
value
)
self
.
_check_
swh
id
(
"
revision
"
,
value
)
@path.validator
@path.validator
def
check_path
(
self
,
attribute
,
value
):
def
check_path
(
self
,
attribute
,
value
):
...
@@ -975,20 +975,20 @@ class RawExtrinsicMetadata(BaseModel):
...
@@ -975,20 +975,20 @@ class RawExtrinsicMetadata(BaseModel):
f
"
Unexpected
'
directory
'
context for
{
self
.
type
.
value
}
object:
{
value
}
"
f
"
Unexpected
'
directory
'
context for
{
self
.
type
.
value
}
object:
{
value
}
"
)
)
self
.
_check_
p
id
(
"
directory
"
,
value
)
self
.
_check_
swh
id
(
"
directory
"
,
value
)
def
_check_
p
id
(
self
,
expected_object_type
,
p
id
):
def
_check_
swh
id
(
self
,
expected_object_type
,
swh
id
):
if
isinstance
(
p
id
,
str
):
if
isinstance
(
swh
id
,
str
):
raise
ValueError
(
f
"
Expected SWHID, got a string:
{
p
id
}
"
)
raise
ValueError
(
f
"
Expected SWHID, got a string:
{
swh
id
}
"
)
if
p
id
.
object_type
!=
expected_object_type
:
if
swh
id
.
object_type
!=
expected_object_type
:
raise
ValueError
(
raise
ValueError
(
f
"
Expected SWHID type
'
{
expected_object_type
}
'
,
"
f
"
Expected SWHID type
'
{
expected_object_type
}
'
,
"
f
"
got
'
{
p
id
.
object_type
}
'
in
{
p
id
}
"
f
"
got
'
{
swh
id
.
object_type
}
'
in
{
swh
id
}
"
)
)
if
p
id
.
metadata
:
if
swh
id
.
metadata
:
raise
ValueError
(
f
"
Expected core SWHID, but got:
{
p
id
}
"
)
raise
ValueError
(
f
"
Expected core SWHID, but got:
{
swh
id
}
"
)
def
to_dict
(
self
):
def
to_dict
(
self
):
d
=
super
().
to_dict
()
d
=
super
().
to_dict
()
...
...
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