Skip to content

Commit 767c84c

Browse files
author
vbuell
committed
javaobj module extracted from peiping project to the new home.
1 parent 5555a2e commit 767c84c

File tree

4 files changed

+25
-115
lines changed

4 files changed

+25
-115
lines changed

eip_tests.py

Lines changed: 0 additions & 25 deletions
This file was deleted.

javaobj.py

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,36 @@
1+
"""Provides functions for reading and writing (writing is WIP currently) Java objects
2+
serialized or will be deserialized by ObjectOutputStream. This form of object
3+
representation is a standard data interchange format in Java world.
4+
5+
javaobj module exposes an API familiar to users of the standard library marshal, pickle and json modules.
6+
7+
See: http://download.oracle.com/javase/6/docs/platform/serialization/spec/protocol.html
8+
"""
9+
110
import StringIO
211
import struct
312

4-
def loads(object):
13+
__version__ = "$Revision: 20 $"
14+
15+
def load(file_object):
516
"""
617
Deserializes Java primitive data and objects serialized by ObjectOutputStream
18+
from a file-like object.
19+
"""
20+
marshaller = JavaObjectUnmarshaller(file_object)
21+
return marshaller.readObject()
22+
23+
24+
def loads(string):
25+
"""
26+
Deserializes Java objects and primitive data serialized by ObjectOutputStream
727
from a string.
8-
See: http://download.oracle.com/javase/6/docs/platform/serialization/spec/protocol.html
928
"""
10-
f = StringIO.StringIO(object)
29+
f = StringIO.StringIO(string)
1130
marshaller = JavaObjectUnmarshaller(f)
1231
return marshaller.readObject()
1332

33+
1434
def dumps(object):
1535
"""
1636
Serializes Java primitive data and objects unmarshaled by load(s) before into string.
@@ -41,6 +61,7 @@ class JavaObject(object):
4161
def get_class(self):
4262
return self.classdesc
4363

64+
4465
class JavaObjectConstants:
4566

4667
STREAM_MAGIC = 0xaced
@@ -408,7 +429,7 @@ def _oops_dump_state(self):
408429
print "Warning!!!!: Stream still has %s bytes left." % len(the_rest)
409430
print self._create_hexdump(the_rest)
410431
print "=" * 30
411-
# =====================================================================================
432+
412433

413434
class JavaObjectMarshaller(JavaObjectConstants):
414435

peiping.py

Lines changed: 0 additions & 41 deletions
This file was deleted.

peiping_http.py

Lines changed: 0 additions & 45 deletions
This file was deleted.

0 commit comments

Comments
 (0)