Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Paste
P635
(An Untitled Masterwork)
Active
Public
Actions
Authored by
douardda
on Apr 2 2020, 4:03 PM.
Edit Paste
Archive Paste
View Raw File
Subscribe
Mute Notifications
Award Token
Flag For Later
Tags
None
Subscribers
None
def
_get_key
(
self
,
object_type
:
str
,
object_
:
BaseModel
)
->
Union
[
bytes
,
Dict
]:
if
object_type
in
(
'revision'
,
'release'
,
'directory'
,
'snapshot'
):
object_
=
cast
(
Union
[
Revision
,
Release
,
Directory
,
Snapshot
],
object_
)
return
object_
.
id
elif
object_type
==
'content'
:
object_
=
cast
(
Content
,
object_
)
return
object_
.
sha1
# TODO: use a dict of hashes
elif
object_type
==
'skipped_content'
:
return
{
hash
:
getattr
(
object_
,
hash
)
for
hash
in
DEFAULT_ALGORITHMS
}
elif
object_type
==
'origin'
:
object_
=
cast
(
Origin
,
object_
)
return
{
'url'
:
object_
.
url
}
elif
object_type
==
'origin_visit'
:
object_
=
cast
(
OriginVisit
,
object_
)
return
{
'origin'
:
object_
.
origin
,
'date'
:
str
(
object_
.
date
),
}
else
:
raise
ValueError
(
'Unknown object type:
%s
.'
%
object_type
)
Event Timeline
douardda
created this paste.
Apr 2 2020, 4:03 PM
2020-04-02 16:03:18 (UTC+2)
Log In to Comment