2363d6de43
git-svn-id: http://google-refine.googlecode.com/svn/trunk@517 7d457c2a-affb-35e4-300a-418c747d4874
29 lines
603 B
Python
29 lines
603 B
Python
"""Marshal module written in Python.
|
|
|
|
This doesn't marshal code objects, but supports everything else.
|
|
Performance or careful error checking is not an issue.
|
|
|
|
"""
|
|
|
|
import cStringIO
|
|
from _marshal import Marshaller, Unmarshaller
|
|
|
|
def dump(x, f, version=2):
|
|
Marshaller(f, version).dump(x)
|
|
|
|
# XXX - added just for debugging. remove!
|
|
def load(f, debug=False):
|
|
u = Unmarshaller(f)
|
|
if debug:
|
|
u._debug()
|
|
return u.load()
|
|
|
|
def dumps(x, version=2):
|
|
f = cStringIO.StringIO()
|
|
dump(x, f, version)
|
|
return f.getvalue()
|
|
|
|
def loads(s):
|
|
f = cStringIO.StringIO(s)
|
|
return load(f)
|