当前位置: 首页>>代码示例>>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;未经允许,请勿转载。