Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F9314387
serial.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
963 B
Subscribers
None
serial.py
View Options
#!/usr/bin/env python3
# Copyright (C) 2015 The Software Heritage developers
# See the AUTHORS file_or_handle at the top-level directory of this distribution
# License: GNU General Public License version 3, or any later version
# See top-level LICENSE file_or_handle for more information
import
pickle
from
io
import
BytesIO
MIMETYPE
=
"application/octet-stream"
def
load
(
file_or_handle
):
"""Read a pickled object from the opened file_or_handle object.
"""
return
pickle
.
load
(
file_or_handle
)
def
loads
(
obj
):
"""Read a pickled object from bytes object.
"""
if
obj
==
b
''
:
return
obj
return
pickle
.
loads
(
obj
)
def
dumps
(
obj
):
"""Return the pickle representation of the obj.
"""
return
pickle
.
dumps
(
obj
,
protocol
=
pickle
.
HIGHEST_PROTOCOL
)
def
dumps_as_stream
(
obj
):
"""Return the pickle representation of the obj as stream.
"""
return
pickle
.
dump
(
obj
,
BytesIO
(),
protocol
=
pickle
.
HIGHEST_PROTOCOL
)
File Metadata
Details
Attached
Mime Type
text/x-python
Expires
Thu, Jul 3, 12:26 PM (2 d, 9 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3240864
Attached To
rDLDG Git loader
Event Timeline
Log In to Comment