当前位置: 首页>>代码示例>>Python>>正文


Python BinaryIO.write方法代码示例

本文整理汇总了Python中typing.BinaryIO.write方法的典型用法代码示例。如果您正苦于以下问题:Python BinaryIO.write方法的具体用法?Python BinaryIO.write怎么用?Python BinaryIO.write使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在typing.BinaryIO的用法示例。


在下文中一共展示了BinaryIO.write方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: save_to

# 需要导入模块: from typing import BinaryIO [as 别名]
# 或者: from typing.BinaryIO import write [as 别名]
 async def save_to(self, name: str, fd: BinaryIO):
     async with ClientSession() as client:
         async with client.post(self.get_url, data=name.encode("utf8")) as resp:
             assert resp.status == 200
             while True:
                 data = await resp.content.read(2 << 20)
                 if not data:
                     break
                 fd.write(data)
开发者ID:Mirantis,项目名称:ceph-monitoring,代码行数:11,代码来源:web_storage.py

示例2: download_into

# 需要导入模块: from typing import BinaryIO [as 别名]
# 或者: from typing.BinaryIO import write [as 别名]
def download_into(session: requests.Session,
                  url: str, file: BinaryIO, process_func=None) -> None:
  r = session.get(url, stream=True)
  length = int(r.headers.get('Content-Length') or 0)
  received = 0
  for chunk in r.iter_content(CHUNK_SIZE):
    received += len(chunk)
    file.write(chunk)
    if process_func:
      process_func(received, length)
  if not length and process_func:
    process_func(received, received)
开发者ID:archlinuxcn,项目名称:lilac,代码行数:14,代码来源:requestsutils.py

示例3: postprocess

# 需要导入模块: from typing import BinaryIO [as 别名]
# 或者: from typing.BinaryIO import write [as 别名]
 def postprocess(self, source: ArchiveView, sink: BinaryIO) -> None:
     if self.details:
         key, amount = self.details
         parts = []
         while amount > 0:
             part = source.read(amount)
             amount -= len(part)
             parts.append(part)
         sink.write(obfuscation_run(b"".join(parts), key))
     else:
         raise Exception("find_offset_and_key must be called before postprocess")
     for segment in iter(source.read1, b""):
         sink.write(segment)
开发者ID:Lattyware,项目名称:unrpa,代码行数:15,代码来源:zix.py

示例4: _rewrite_ownership_v0

# 需要导入模块: from typing import BinaryIO [as 别名]
# 或者: from typing.BinaryIO import write [as 别名]
def _rewrite_ownership_v0(
    input_file: BinaryIO, new_file: BinaryIO, header: MdvHeader, uid: int, gid: int
) -> None:
    entries_processed = 0
    entry_size = InodeMetadataV0.FORMAT.size
    for _ in range(header.entry_count):
        entries_processed += 1

        entry_data = input_file.read(entry_size)
        if len(entry_data) != entry_size:
            raise Exception("inode metadata table appears truncated")

        entry = InodeMetadataV0.parse(entry_data)
        entry.uid = uid
        entry.gid = gid
        new_file.write(entry.serialize())

    # Copy the remaining file contents as is.  This is normally all 0-filled data
    # that provides space for new entries to be written in the future.
    padding = input_file.read()
    new_file.write(padding)
开发者ID:facebookexperimental,项目名称:eden,代码行数:23,代码来源:inode_metadata.py

示例5: dump

# 需要导入模块: from typing import BinaryIO [as 别名]
# 或者: from typing.BinaryIO import write [as 别名]
def dump(value: TSerializable, file_handle: typing.BinaryIO) -> None:
    """
    This function dumps a python object as a tnetstring and
    writes it to the given file.
    """
    file_handle.write(dumps(value))
开发者ID:StevenVanAcker,项目名称:mitmproxy,代码行数:8,代码来源:tnetstring.py

示例6: postprocess

# 需要导入模块: from typing import BinaryIO [as 别名]
# 或者: from typing.BinaryIO import write [as 别名]
 def postprocess(self, source: ArchiveView, sink: BinaryIO) -> None:
     """Allows postprocessing over the data extracted from the archive."""
     for segment in iter(source.read1, b""):
         sink.write(segment)
开发者ID:Lattyware,项目名称:unrpa,代码行数:6,代码来源:version.py


注:本文中的typing.BinaryIO.write方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。