blob: 86d8b03a6f41e0caf433bbc335c367fe846bbd35 [file] [log] [blame]
try:
from cStringIO import StringIO
except ImportError:
from StringIO import StringIO
try:
from struct import Struct as Packer
except ImportError:
from struct import pack, unpack, calcsize
class Packer(object):
__slots__ = ["format", "size"]
def __init__(self, format):
self.format = format
self.size = calcsize(format)
def pack(self, *args):
return pack(self.format, *args)
def unpack(self, data):
return unpack(self.format, data)