Lines Matching refs:fileobj
46 compresslevel=9, fileobj=None, mtime=None):
49 At least one of fileobj and filename must be given a
52 The new class instance is based on fileobj, which can be a regular
57 When fileobj is not None, the filename argument is only used to be
60 fileobj, if discernible; otherwise, it defaults to the empty string,
65 is the mode of fileobj if discernible; otherwise, the default is 'rb'.
88 if fileobj is None:
89 fileobj = self.myfileobj = __builtin__.open(filename, mode or 'rb')
91 if hasattr(fileobj, 'name'): filename = fileobj.name
94 if hasattr(fileobj, 'mode'): mode = fileobj.mode
122 self.fileobj = fileobj
138 s = repr(self.fileobj)
156 self.fileobj.write('\037\213') # magic header
157 self.fileobj.write('\010') # compression method
164 self.fileobj.write(chr(flags))
168 write32u(self.fileobj, long(mtime))
169 self.fileobj.write('\002')
170 self.fileobj.write('\377')
172 self.fileobj.write(fname + '\000')
179 magic = self.fileobj.read(2)
182 method = ord( self.fileobj.read(1) )
185 flag = ord( self.fileobj.read(1) )
186 self.mtime = read32(self.fileobj)
187 # extraflag = self.fileobj.read(1)
188 # os = self.fileobj.read(1)
189 self.fileobj.read(2)
193 xlen = ord(self.fileobj.read(1))
194 xlen = xlen + 256*ord(self.fileobj.read(1))
195 self.fileobj.read(xlen)
199 s = self.fileobj.read(1)
205 s = self.fileobj.read(1)
209 self.fileobj.read(2) # Read & discard the 16-bit header CRC
217 if self.fileobj is None:
227 self.fileobj.write( self.compress.compress(data) )
238 if self.extrasize <= 0 and self.fileobj is None:
270 if self.fileobj is None:
279 pos = self.fileobj.tell() # Save current position
280 self.fileobj.seek(0, 2) # Seek to end of file
281 if pos == self.fileobj.tell():
284 self.fileobj.seek( pos ) # Return to original position
292 buf = self.fileobj.read(size)
312 self.fileobj.seek( -len(self.decompress.unused_data)+8, 1)
333 self.fileobj.seek(-8, 1)
334 crc32 = read32(self.fileobj)
335 isize = read32(self.fileobj) # may exceed 2GB
347 c = self.fileobj.read(1)
349 self.fileobj.seek(-1, 1)
353 return self.fileobj is None
356 if self.fileobj is None:
359 self.fileobj.write(self.compress.flush())
360 write32u(self.fileobj, self.crc)
362 write32u(self.fileobj, self.size & 0xffffffffL)
363 self.fileobj = None
365 self.fileobj = None
374 self.fileobj.write(self.compress.flush(zlib_mode))
375 self.fileobj.flush()
383 return self.fileobj.fileno()
390 self.fileobj.seek(0)
483 f = GzipFile(filename="", mode="rb", fileobj=sys.stdin)
494 g = GzipFile(filename="", mode="wb", fileobj=sys.stdout)