當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。