Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Paste
P636
(An Untitled Masterwork)
Active
Public
Actions
Authored by
douardda
on Apr 2 2020, 4:22 PM.
Edit Paste
Archive Paste
View Raw File
Subscribe
Mute Notifications
Award Token
Flag For Later
Tags
None
Subscribers
None
@overload
def
_get_key
(
self
,
object_type
:
str
,
object_
:
Union
[
Revision
,
Release
,
Directory
,
Snapshot
])
->
bytes
:
...
@overload
def
_get_key
(
self
,
object_type
:
str
,
object_
:
Content
)
->
bytes
:
...
@overload
def
_get_key
(
self
,
object_type
:
str
,
object_
:
SkippedContent
)
->
Dict
[
str
,
bytes
]:
...
@overload
def
_get_key
(
self
,
object_type
:
str
,
object_
:
Origin
)
->
Dict
[
str
,
bytes
]:
...
@overload
def
_get_key
(
self
,
object_type
:
str
,
object_
:
OriginVisit
)
->
Dict
[
str
,
str
]:
...
def
_get_key
(
self
,
object_type
:
str
,
object_
:
BaseModel
)
->
Union
[
bytes
,
Dict
]:
if
object_type
in
(
"revision"
,
"release"
,
"directory"
,
"snapshot"
):
return
object_
.
id
elif
object_type
==
"content"
:
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"
:
return
{
"url"
:
object_
.
url
}
elif
object_type
==
"origin_visit"
:
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:22 PM
2020-04-02 16:22:47 (UTC+2)
Log In to Comment