Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes | Private Member Functions
binhex._Rledecoderengine Class Reference

List of all members.

Public Member Functions

def __init__
def read
def close

Public Attributes

 ifp
 pre_buffer
 post_buffer
 eof

Private Member Functions

def _fill

Detailed Description

Read data via the RLE-coder

Definition at line 292 of file binhex.py.


Constructor & Destructor Documentation

def binhex._Rledecoderengine.__init__ (   self,
  ifp 
)

Definition at line 295 of file binhex.py.

00295 
00296     def __init__(self, ifp):
00297         self.ifp = ifp
00298         self.pre_buffer = b''
00299         self.post_buffer = b''
00300         self.eof = 0

Here is the caller graph for this function:


Member Function Documentation

def binhex._Rledecoderengine._fill (   self,
  wtd 
) [private]

Definition at line 308 of file binhex.py.

00308 
00309     def _fill(self, wtd):
00310         self.pre_buffer = self.pre_buffer + self.ifp.read(wtd + 4)
00311         if self.ifp.eof:
00312             self.post_buffer = self.post_buffer + \
00313                 binascii.rledecode_hqx(self.pre_buffer)
00314             self.pre_buffer = b''
00315             return
00316 
00317         #
00318         # Obfuscated code ahead. We have to take care that we don't
00319         # end up with an orphaned RUNCHAR later on. So, we keep a couple
00320         # of bytes in the buffer, depending on what the end of
00321         # the buffer looks like:
00322         # '\220\0\220' - Keep 3 bytes: repeated \220 (escaped as \220\0)
00323         # '?\220' - Keep 2 bytes: repeated something-else
00324         # '\220\0' - Escaped \220: Keep 2 bytes.
00325         # '?\220?' - Complete repeat sequence: decode all
00326         # otherwise: keep 1 byte.
00327         #
00328         mark = len(self.pre_buffer)
00329         if self.pre_buffer[-3:] == RUNCHAR + b'\0' + RUNCHAR:
00330             mark = mark - 3
00331         elif self.pre_buffer[-1:] == RUNCHAR:
00332             mark = mark - 2
00333         elif self.pre_buffer[-2:] == RUNCHAR + b'\0':
00334             mark = mark - 2
00335         elif self.pre_buffer[-2:-1] == RUNCHAR:
00336             pass # Decode all
00337         else:
00338             mark = mark - 1
00339 
00340         self.post_buffer = self.post_buffer + \
00341             binascii.rledecode_hqx(self.pre_buffer[:mark])
00342         self.pre_buffer = self.pre_buffer[mark:]

Here is the caller graph for this function:

Definition at line 343 of file binhex.py.

00343 
00344     def close(self):
00345         self.ifp.close()

def binhex._Rledecoderengine.read (   self,
  wtd 
)

Definition at line 301 of file binhex.py.

00301 
00302     def read(self, wtd):
00303         if wtd > len(self.post_buffer):
00304             self._fill(wtd - len(self.post_buffer))
00305         rv = self.post_buffer[:wtd]
00306         self.post_buffer = self.post_buffer[wtd:]
00307         return rv

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 299 of file binhex.py.

Definition at line 296 of file binhex.py.

Definition at line 298 of file binhex.py.

Definition at line 297 of file binhex.py.


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