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'.
93 if fileobj is None:
94 fileobj = self.myfileobj = __builtin__.open(filename, mode or 'rb')
96 # Issue #13781: os.fdopen() creates a fileobj with a bogus name
98 if hasattr(fileobj, 'name') and fileobj.name != '<fdopen>':
99 filename = fileobj.name
103 if hasattr(fileobj, 'mode'): mode = fileobj.mode
131 self.fileobj = fileobj
147 s = repr(self.fileobj)
165 self.fileobj.write('\037\213') # magic header
166 self.fileobj.write('\010') # compression method
173 self.fileobj.write(chr(flags))
177 write32u(self.fileobj, long(mtime))
178 self.fileobj.write('\002')
179 self.fileobj.write('\377')
181 self.fileobj.write(fname + '\000')
188 magic = self.fileobj.read(2)
191 method = ord( self.fileobj.read(1) )
194 flag = ord( self.fileobj.read(1) )
195 self.mtime = read32(self.fileobj)
196 # extraflag = self.fileobj.read(1)
197 # os = self.fileobj.read(1)
198 self.fileobj.read(2)
202 xlen = ord(self.fileobj.read(1))
203 xlen = xlen + 256*ord(self.fileobj.read(1))
204 self.fileobj.read(xlen)
208 s = self.fileobj.read(1)
214 s = self.fileobj.read(1)
218 self.fileobj.read(2) # Read & discard the 16-bit header CRC
226 if self.fileobj is None:
236 self.fileobj.write( self.compress.compress(data) )
247 if self.extrasize <= 0 and self.fileobj is None:
279 if self.fileobj is None:
288 pos = self.fileobj.tell() # Save current position
289 self.fileobj.seek(0, 2) # Seek to end of file
290 if pos == self.fileobj.tell():
293 self.fileobj.seek( pos ) # Return to original position
301 buf = self.fileobj.read(size)
321 self.fileobj.seek( -len(self.decompress.unused_data)+8, 1)
342 self.fileobj.seek(-8, 1)
343 crc32 = read32(self.fileobj)
344 isize = read32(self.fileobj) # may exceed 2GB
356 c = self.fileobj.read(1)
358 self.fileobj.seek(-1, 1)
362 return self.fileobj is None
365 if self.fileobj is None:
368 self.fileobj.write(self.compress.flush())
369 write32u(self.fileobj, self.crc)
371 write32u(self.fileobj, self.size & 0xffffffffL)
372 self.fileobj = None
374 self.fileobj = None
383 self.fileobj.write(self.compress.flush(zlib_mode))
384 self.fileobj.flush()
392 return self.fileobj.fileno()
399 self.fileobj.seek(0)
492 f = GzipFile(filename="", mode="rb", fileobj=sys.stdin)
503 g = GzipFile(filename="", mode="wb", fileobj=sys.stdout)