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


Python BytesIO.seek方法代碼示例

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


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

示例1: _read

# 需要導入模塊: from storages.compat import BytesIO [as 別名]
# 或者: from storages.compat.BytesIO import seek [as 別名]
 def _read(self, name):
     memory_file = BytesIO()
     try:
         pwd = self._connection.pwd()
         self._connection.cwd(os.path.dirname(name))
         self._connection.retrbinary('RETR ' + os.path.basename(name),
                                     memory_file.write)
         self._connection.cwd(pwd)
         memory_file.seek(0)
         return memory_file
     except ftplib.all_errors:
         raise FTPStorageException('Error reading file %s' % name)
開發者ID:BBKolton,項目名稱:ml4,代碼行數:14,代碼來源:ftp.py

示例2: _compress_content

# 需要導入模塊: from storages.compat import BytesIO [as 別名]
# 或者: from storages.compat.BytesIO import seek [as 別名]
 def _compress_content(self, content):
     """Gzip a given string content."""
     zbuf = BytesIO()
     zfile = GzipFile(mode="wb", compresslevel=6, fileobj=zbuf)
     try:
         zfile.write(force_bytes(content.read()))
     finally:
         zfile.close()
     zbuf.seek(0)
     content.file = zbuf
     content.seek(0)
     return content
開發者ID:thenewguy,項目名稱:django-storages,代碼行數:14,代碼來源:s3boto.py

示例3: _compress_content

# 需要導入模塊: from storages.compat import BytesIO [as 別名]
# 或者: from storages.compat.BytesIO import seek [as 別名]
 def _compress_content(self, content):
     """Gzip a given string content."""
     zbuf = BytesIO()
     zfile = GzipFile(mode='wb', compresslevel=6, fileobj=zbuf)
     try:
         zfile.write(force_bytes(content.read()))
     finally:
         zfile.close()
     zbuf.seek(0)
     # Boto 2 returned the InMemoryUploadedFile with the file pointer replaced,
     # but Boto 3 seems to have issues with that. No need for fp.name in Boto3
     # so just returning the BytesIO directly
     return zbuf
開發者ID:BBKolton,項目名稱:ml4,代碼行數:15,代碼來源:s3boto3.py

示例4: _compress_content

# 需要導入模塊: from storages.compat import BytesIO [as 別名]
# 或者: from storages.compat.BytesIO import seek [as 別名]
 def _compress_content(self, content):
     """Gzip a given string content."""
     zbuf = BytesIO()
     #  The GZIP header has a modification time attribute (see http://www.zlib.org/rfc-gzip.html)
     #  This means each time a file is compressed it changes even if the other contents don't change
     #  For S3 this defeats detection of changes using MD5 sums on gzipped files
     #  Fixing the mtime at 0.0 at compression time avoids this problem
     zfile = GzipFile(mode="wb", compresslevel=6, fileobj=zbuf, mtime=0.0)
     try:
         zfile.write(force_bytes(content.read()))
     finally:
         zfile.close()
     zbuf.seek(0)
     content.file = zbuf
     content.seek(0)
     return content
開發者ID:tellybug,項目名稱:django-storages-1,代碼行數:18,代碼來源:s3boto.py


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