parameters: (self, totalwtd)
return_statement: return decdata
docstring: Read at least wtd bytes (or until EOF)
docstring_summary: Read at least wtd bytes (or until EOF)
docstring_tokens: Read at least wtd bytes ( or until EOF )
function: def read(self, totalwtd):
          """Read at least wtd bytes (or until EOF)"""
          decdata = ''
          wtd = totalwtd
          #
          # The loop here is convoluted, since we don't really now how
          # much to decode: there may be newlines in the incoming data.
          while wtd > 0:
              if self.eof: return decdata
              wtd = ((wtd+2)//3)*4
              data = self.ifp.read(wtd)
              #
              # Next problem: there may not be a complete number of
              # bytes in what we pass to a2b. Solve by yet another
              # loop.
              #
              while 1:
                  try:
                      decdatacur, self.eof = \
                              binascii.a2b_hqx(data)
                      break
                  except binascii.Incomplete:
                      pass
                  newdata = self.ifp.read(1)
                  if not newdata:
                      raise Error, \
                            'Premature EOF on binhex file'
                  data = data + newdata
              decdata = decdata + decdatacur
              wtd = totalwtd - len(decdata)
              if not decdata and not self.eof:
                  raise Error, 'Premature EOF on binhex file'
          return decdata
function_tokens: def read ( self , totalwtd ) : decdata = '' wtd = totalwtd # # The loop here is convoluted, since we don't really now how # much to decode: there may be newlines in the incoming data. while wtd > 0 : if self . eof : return decdata wtd = ( ( wtd + 2 ) // 3 ) * 4 data = self . ifp . read ( wtd ) # # Next problem: there may not be a complete number of # bytes in what we pass to a2b. Solve by yet another # loop. # while 1 : try : decdatacur , self . eof = binascii . a2b_hqx ( data ) break except binascii . Incomplete : pass newdata = self . ifp . read ( 1 ) if not newdata : raise Error , 'Premature EOF on binhex file' data = data + newdata decdata = decdata + decdatacur wtd = totalwtd - len ( decdata ) if not decdata and not self . eof : raise Error , 'Premature EOF on binhex file' return decdata