Python gzip.WRITE Examples
The following are 5
code examples of gzip.WRITE().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
gzip
, or try the search function
.
Example #1
Source File: geezip.py From bazarr with GNU General Public License v3.0 | 6 votes |
def close(self): fileobj = self.fileobj if fileobj is None: return self.fileobj = None try: if self.mode == gzip.WRITE: fileobj.write(self.compress.flush(Z_FINISH)) gzip.write32u(fileobj, self.crc) # self.size may exceed 2GB, or even 4GB gzip.write32u(fileobj, self.size & 0xffffffff) fileobj.flush() finally: myfileobj = self.myfileobj if myfileobj: self.myfileobj = None myfileobj.close()
Example #2
Source File: util.py From Carnets with BSD 3-Clause "New" or "Revised" License | 6 votes |
def _fileobj_normalize_mode(f): """Takes care of some corner cases in Python where the mode string is either oddly formatted or does not truly represent the file mode. """ mode = f.mode # Special case: Gzip modes: if isinstance(f, gzip.GzipFile): # GzipFiles can be either readonly or writeonly if mode == gzip.READ: return 'rb' elif mode == gzip.WRITE: return 'wb' else: return None # This shouldn't happen? # Sometimes Python can produce modes like 'r+b' which will be normalized # here to 'rb+' if '+' in mode: mode = mode.replace('+', '') mode += '+' return mode
Example #3
Source File: data.py From razzy-spinner with GNU General Public License v3.0 | 5 votes |
def close(self): # GzipFile.close() doesn't actuallly close anything. if self.mode == GZ_WRITE: self._write_gzip(None) self._reset_buffer() return GzipFile.close(self)
Example #4
Source File: data.py From luscan-devel with GNU General Public License v2.0 | 5 votes |
def close(self): # GzipFile.close() doesn't actuallly close anything. if self.mode == GZ_WRITE: self._write_gzip(None) self._reset_buffer() return GzipFile.close(self)
Example #5
Source File: data.py From V1EngineeringInc-Docs with Creative Commons Attribution Share Alike 4.0 International | 5 votes |
def close(self): # GzipFile.close() doesn't actuallly close anything. if self.mode == GZ_WRITE: self._write_gzip(None) self._reset_buffer() return GzipFile.close(self)