Back to index

enigmail  1.4.3
Public Member Functions | Public Attributes
optimizejars.BinaryBlob Class Reference

List of all members.

Public Member Functions

def __init__
def readAt
def read_struct

Public Attributes

 data
 offset
 length

Detailed Description

Definition at line 150 of file optimizejars.py.


Constructor & Destructor Documentation

def optimizejars.BinaryBlob.__init__ (   self,
  f 
)

Definition at line 151 of file optimizejars.py.

00151 
00152     def __init__(self, f):
00153        self.data = open(f, "rb").read()
00154        self.offset = 0
00155        self.length = len(self.data)


Member Function Documentation

def optimizejars.BinaryBlob.read_struct (   self,
  format,
  offset = None 
)

Definition at line 160 of file optimizejars.py.

00160 
00161     def read_struct (self, format, offset = None):
00162         if offset == None:
00163             offset = self.offset
00164         (fstr, string_fields) = format_struct(format)
00165         size = struct.calcsize(fstr)
00166         data = self.readAt(offset, size)
00167         ret = struct.unpack(fstr, data)
00168         retstruct = MyStruct(format, string_fields)
00169         i = 0
00170         for (name,_) in iter(format):
00171             member_desc = None
00172             if not name in string_fields:
00173                 member_data = ret[i]
00174                 i = i + 1
00175             else:
00176                 # zip has data fields which are described by other struct fields, this does 
00177                 # additional reads to fill em in
00178                 member_desc = string_fields[name]
00179                 member_data = self.readAt(self.offset, retstruct.__getattr__(member_desc))
00180             retstruct.addMember(name, member_data)
00181         # sanity check serialization code
00182         data = self.readAt(offset, self.offset - offset)
00183         out_data = retstruct.pack()
00184         assert_true(out_data == data, "Serialization fail %d !=%d"% (len(out_data), len(data)))
00185         return retstruct

Here is the call graph for this function:

def optimizejars.BinaryBlob.readAt (   self,
  pos,
  length 
)

Definition at line 156 of file optimizejars.py.

00156 
00157     def readAt(self, pos, length):
00158         self.offset = pos + length
00159         return self.data[pos:self.offset]

Here is the caller graph for this function:


Member Data Documentation

Definition at line 152 of file optimizejars.py.

Definition at line 154 of file optimizejars.py.

Definition at line 153 of file optimizejars.py.


The documentation for this class was generated from the following file: