parameters: (self, n)
return_statement: return data
docstring: Read up to n bytes with at most one read() system call.
docstring_summary: Read up to n bytes with at most one read() system call.
docstring_tokens: Read up to n bytes with at most one read () system call .
function: def read1(self, n):
          """Read up to n bytes with at most one read() system call."""
  
          # Simplify algorithm (branching) by transforming negative n to large n.
          if n < 0 or n is None:
              n = self.MAX_N
  
          # Bytes available in read buffer.
          len_readbuffer = len(self._readbuffer) - self._offset
  
          # Read from file.
          if self._compress_left > 0 and n > len_readbuffer + len(self._unconsumed):
              nbytes = n - len_readbuffer - len(self._unconsumed)
              nbytes = max(nbytes, self.MIN_READ_SIZE)
              nbytes = min(nbytes, self._compress_left)
  
              data = self._fileobj.read(nbytes)
              self._compress_left -= len(data)
  
              if data and self._decrypter is not None:
                  data = ''.join(map(self._decrypter, data))
  
              if self._compress_type == ZIP_STORED:
                  self._update_crc(data, eof=(self._compress_left==0))
                  self._readbuffer = self._readbuffer[self._offset:] + data
                  self._offset = 0
              else:
                  # Prepare deflated bytes for decompression.
                  self._unconsumed += data
  
          # Handle unconsumed data.
          if (len(self._unconsumed) > 0 and n > len_readbuffer and
              self._compress_type == ZIP_DEFLATED):
              data = self._decompressor.decompress(
                  self._unconsumed,
                  max(n - len_readbuffer, self.MIN_READ_SIZE)
              )
  
              self._unconsumed = self._decompressor.unconsumed_tail
              eof = len(self._unconsumed) == 0 and self._compress_left == 0
              if eof:
                  data += self._decompressor.flush()
  
              self._update_crc(data, eof=eof)
              self._readbuffer = self._readbuffer[self._offset:] + data
              self._offset = 0
  
          # Read from buffer.
          data = self._readbuffer[self._offset: self._offset + n]
          self._offset += len(data)
          return data
function_tokens: def read1 ( self , n ) : # Simplify algorithm (branching) by transforming negative n to large n. if n < 0 or n is None : n = self . MAX_N # Bytes available in read buffer. len_readbuffer = len ( self . _readbuffer ) - self . _offset # Read from file. if self . _compress_left > 0 and n > len_readbuffer + len ( self . _unconsumed ) : nbytes = n - len_readbuffer - len ( self . _unconsumed ) nbytes = max ( nbytes , self . MIN_READ_SIZE ) nbytes = min ( nbytes , self . _compress_left ) data = self . _fileobj . read ( nbytes ) self . _compress_left -= len ( data ) if data and self . _decrypter is not None : data = '' . join ( map ( self . _decrypter , data ) ) if self . _compress_type == ZIP_STORED : self . _update_crc ( data , eof = ( self . _compress_left == 0 ) ) self . _readbuffer = self . _readbuffer [ self . _offset : ] + data self . _offset = 0 else : # Prepare deflated bytes for decompression. self . _unconsumed += data # Handle unconsumed data. if ( len ( self . _unconsumed ) > 0 and n > len_readbuffer and self . _compress_type == ZIP_DEFLATED ) : data = self . _decompressor . decompress ( self . _unconsumed , max ( n - len_readbuffer , self . MIN_READ_SIZE ) ) self . _unconsumed = self . _decompressor . unconsumed_tail eof = len ( self . _unconsumed ) == 0 and self . _compress_left == 0 if eof : data += self . _decompressor . flush ( ) self . _update_crc ( data , eof = eof ) self . _readbuffer = self . _readbuffer [ self . _offset : ] + data self . _offset = 0 # Read from buffer. data = self . _readbuffer [ self . _offset : self . _offset + n ] self . _offset += len ( data ) return data