Lines Matching refs:fileobj
46 compresslevel=9, fileobj=None, mtime=None): argument
93 if fileobj is None:
94 fileobj = self.myfileobj = __builtin__.open(filename, mode or 'rb')
98 filename = getattr(fileobj, 'name', '')
102 if hasattr(fileobj, 'mode'): mode = fileobj.mode
130 self.fileobj = fileobj
146 s = repr(self.fileobj)
164 self.fileobj.write('\037\213') # magic header
165 self.fileobj.write('\010') # compression method
179 self.fileobj.write(chr(flags))
183 write32u(self.fileobj, long(mtime))
184 self.fileobj.write('\002')
185 self.fileobj.write('\377')
187 self.fileobj.write(fname + '\000')
194 magic = self.fileobj.read(2)
197 method = ord( self.fileobj.read(1) )
200 flag = ord( self.fileobj.read(1) )
201 self.mtime = read32(self.fileobj)
204 self.fileobj.read(2)
208 xlen = ord(self.fileobj.read(1))
209 xlen = xlen + 256*ord(self.fileobj.read(1))
210 self.fileobj.read(xlen)
214 s = self.fileobj.read(1)
220 s = self.fileobj.read(1)
224 self.fileobj.read(2) # Read & discard the 16-bit header CRC
232 if self.fileobj is None:
240 self.fileobj.write(self.compress.compress(data))
253 if self.extrasize <= 0 and self.fileobj is None:
285 if self.fileobj is None:
294 pos = self.fileobj.tell() # Save current position
295 self.fileobj.seek(0, 2) # Seek to end of file
296 if pos == self.fileobj.tell():
299 self.fileobj.seek( pos ) # Return to original position
307 buf = self.fileobj.read(size)
327 self.fileobj.seek( -len(self.decompress.unused_data)+8, 1)
348 self.fileobj.seek(-8, 1)
349 crc32 = read32(self.fileobj)
350 isize = read32(self.fileobj) # may exceed 2GB
362 c = self.fileobj.read(1)
364 self.fileobj.seek(-1, 1)
368 return self.fileobj is None
371 fileobj = self.fileobj
372 if fileobj is None:
374 self.fileobj = None
377 fileobj.write(self.compress.flush())
378 write32u(fileobj, self.crc)
380 write32u(fileobj, self.size & 0xffffffffL)
391 self.fileobj.write(self.compress.flush(zlib_mode))
392 self.fileobj.flush()
400 return self.fileobj.fileno()
407 self.fileobj.seek(0)
500 f = GzipFile(filename="", mode="rb", fileobj=sys.stdin)
511 g = GzipFile(filename="", mode="wb", fileobj=sys.stdout)