Back to index

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

List of all members.

Public Member Functions

def __init__
def read
def close

Public Attributes

 ifp
 eof

Detailed Description

Read data via the decoder in 4-byte chunks

Definition at line 250 of file binhex.py.


Constructor & Destructor Documentation

def binhex._Hqxdecoderengine.__init__ (   self,
  ifp 
)

Definition at line 253 of file binhex.py.

00253 
00254     def __init__(self, ifp):
00255         self.ifp = ifp
00256         self.eof = 0

Here is the caller graph for this function:


Member Function Documentation

Definition at line 289 of file binhex.py.

00289 
00290     def close(self):
00291         self.ifp.close()

def binhex._Hqxdecoderengine.read (   self,
  totalwtd 
)
Read at least wtd bytes (or until EOF)

Definition at line 257 of file binhex.py.

00257 
00258     def read(self, totalwtd):
00259         """Read at least wtd bytes (or until EOF)"""
00260         decdata = b''
00261         wtd = totalwtd
00262         #
00263         # The loop here is convoluted, since we don't really now how
00264         # much to decode: there may be newlines in the incoming data.
00265         while wtd > 0:
00266             if self.eof: return decdata
00267             wtd = ((wtd + 2) // 3) * 4
00268             data = self.ifp.read(wtd)
00269             #
00270             # Next problem: there may not be a complete number of
00271             # bytes in what we pass to a2b. Solve by yet another
00272             # loop.
00273             #
00274             while True:
00275                 try:
00276                     decdatacur, self.eof = binascii.a2b_hqx(data)
00277                     break
00278                 except binascii.Incomplete:
00279                     pass
00280                 newdata = self.ifp.read(1)
00281                 if not newdata:
00282                     raise Error('Premature EOF on binhex file')
00283                 data = data + newdata
00284             decdata = decdata + decdatacur
00285             wtd = totalwtd - len(decdata)
00286             if not decdata and not self.eof:
00287                 raise Error('Premature EOF on binhex file')
00288         return decdata

Here is the caller graph for this function:


Member Data Documentation

Definition at line 255 of file binhex.py.

Definition at line 254 of file binhex.py.


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