當前位置: 首頁>>代碼示例>>Python>>正文


Python gzip.WRITE屬性代碼示例

本文整理匯總了Python中gzip.WRITE屬性的典型用法代碼示例。如果您正苦於以下問題:Python gzip.WRITE屬性的具體用法?Python gzip.WRITE怎麽用?Python gzip.WRITE使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在gzip的用法示例。


在下文中一共展示了gzip.WRITE屬性的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: close

# 需要導入模塊: import gzip [as 別名]
# 或者: from gzip import WRITE [as 別名]
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() 
開發者ID:morpheus65535,項目名稱:bazarr,代碼行數:19,代碼來源:geezip.py

示例2: _fileobj_normalize_mode

# 需要導入模塊: import gzip [as 別名]
# 或者: from gzip import WRITE [as 別名]
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 
開發者ID:holzschu,項目名稱:Carnets,代碼行數:25,代碼來源:util.py

示例3: close

# 需要導入模塊: import gzip [as 別名]
# 或者: from gzip import WRITE [as 別名]
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) 
開發者ID:rafasashi,項目名稱:razzy-spinner,代碼行數:8,代碼來源:data.py


注:本文中的gzip.WRITE屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。