Vega strike Python Modules doc  0.5.1
Documentation of the " Modules " folder of Vega strike
 All Data Structures Namespaces Files Functions Variables
_Hqxdecoderengine Class Reference

Public Member Functions

def __init__
 
def read
 
def close
 

Data Fields

 ifp
 
 eof
 

Detailed Description

Read data via the decoder in 4-byte chunks

Definition at line 279 of file binhex.py.

Constructor & Destructor Documentation

def __init__ (   self,
  ifp 
)

Definition at line 282 of file binhex.py.

283  def __init__(self, ifp):
284  self.ifp = ifp
285  self.eof = 0

Member Function Documentation

def close (   self)

Definition at line 320 of file binhex.py.

321  def close(self):
322  self.ifp.close()
def read (   self,
  totalwtd 
)
Read at least wtd bytes (or until EOF)

Definition at line 286 of file binhex.py.

References _Hqxdecoderengine.eof.

287  def read(self, totalwtd):
288  """Read at least wtd bytes (or until EOF)"""
289  decdata = ''
290  wtd = totalwtd
291  #
292  # The loop here is convoluted, since we don't really now how
293  # much to decode: there may be newlines in the incoming data.
294  while wtd > 0:
295  if self.eof: return decdata
296  wtd = ((wtd+2)//3)*4
297  data = self.ifp.read(wtd)
298  #
299  # Next problem: there may not be a complete number of
300  # bytes in what we pass to a2b. Solve by yet another
301  # loop.
302  #
303  while 1:
304  try:
305  decdatacur, self.eof = \
306  binascii.a2b_hqx(data)
307  break
308  except binascii.Incomplete:
309  pass
310  newdata = self.ifp.read(1)
311  if not newdata:
312  raise Error, \
313  'Premature EOF on binhex file'
314  data = data + newdata
315  decdata = decdata + decdatacur
316  wtd = totalwtd - len(decdata)
317  if not decdata and not self.eof:
318  raise Error, 'Premature EOF on binhex file'
319  return decdata

Field Documentation

eof

Definition at line 284 of file binhex.py.

ifp

Definition at line 283 of file binhex.py.


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