flytekit.clis.sdk_in_container.init
Directory
Classes
Class | Description |
---|---|
BytesIO |
Buffered I/O implementation using an in-memory bytes buffer. |
ZipFile |
Class with methods to open, read, write, close, list zip files. |
flytekit.clis.sdk_in_container.init.BytesIO
Buffered I/O implementation using an in-memory bytes buffer.
flytekit.clis.sdk_in_container.init.ZipFile
Class with methods to open, read, write, close, list zip files.
z = ZipFile(file, mode=“r”, compression=ZIP_STORED, allowZip64=True, compresslevel=None)
file: Either the path to the file, or a file-like object. If it is a path, the file will be opened and closed by ZipFile. mode: The mode can be either read ‘r’, write ‘w’, exclusive create ‘x’, or append ‘a’. compression: ZIP_STORED (no compression), ZIP_DEFLATED (requires zlib), ZIP_BZIP2 (requires bz2) or ZIP_LZMA (requires lzma). allowZip64: if True ZipFile will create files with ZIP64 extensions when needed, otherwise it will raise an exception when this would be necessary. compresslevel: None (default for the given compression type) or an integer specifying the level to pass to the compressor. When using ZIP_STORED or ZIP_LZMA this keyword has no effect. When using ZIP_DEFLATED integers 0 through 9 are accepted. When using ZIP_BZIP2 integers 1 through 9 are accepted.
def ZipFile(
file,
mode,
compression,
allowZip64,
compresslevel,
strict_timestamps,
metadata_encoding,
):
Open the ZIP file with mode read ‘r’, write ‘w’, exclusive create ‘x’, or append ‘a’.
Parameter | Type |
---|---|
file |
|
mode |
|
compression |
|
allowZip64 |
|
compresslevel |
|
strict_timestamps |
|
metadata_encoding |
Methods
Method | Description |
---|---|
close() |
Close the file, and for mode ‘w’, ‘x’ and ‘a’ write the ending |
extract() |
Extract a member from the archive to the current working directory, |
extractall() |
Extract all members from the archive to the current working |
getinfo() |
Return the instance of ZipInfo given ’name’ |
infolist() |
Return a list of class ZipInfo instances for files in the |
mkdir() |
Creates a directory inside the zip archive |
namelist() |
Return a list of file names in the archive |
open() |
Return file-like object for ’name’ |
printdir() |
Print a table of contents for the zip file |
read() |
Return file bytes for name |
setpassword() |
Set default password for encrypted files |
testzip() |
Read all the files and check the CRC |
write() |
Put the bytes from filename into the archive under the name |
writestr() |
Write a file into the archive |
close()
def close()
Close the file, and for mode ‘w’, ‘x’ and ‘a’ write the ending records.
extract()
def extract(
member,
path,
pwd,
):
Extract a member from the archive to the current working directory,
using its full name. Its file information is extracted as accurately
as possible. member' may be a filename or a ZipInfo object. You can specify a different directory using
path’. You can specify the
password to decrypt the file using ‘pwd’.
Parameter | Type |
---|---|
member |
|
path |
|
pwd |
extractall()
def extractall(
path,
members,
pwd,
):
Extract all members from the archive to the current working
directory. path' specifies a different directory to extract to.
members’ is optional and must be a subset of the list returned
by namelist(). You can specify the password to decrypt all files
using ‘pwd’.
Parameter | Type |
---|---|
path |
|
members |
|
pwd |
getinfo()
def getinfo(
name,
):
Return the instance of ZipInfo given ’name’.
Parameter | Type |
---|---|
name |
infolist()
def infolist()
Return a list of class ZipInfo instances for files in the archive.
mkdir()
def mkdir(
zinfo_or_directory_name,
mode,
):
Creates a directory inside the zip archive.
Parameter | Type |
---|---|
zinfo_or_directory_name |
|
mode |
namelist()
def namelist()
Return a list of file names in the archive.
open()
def open(
name,
mode,
pwd,
force_zip64,
):
Return file-like object for ’name’.
name is a string for the file name within the ZIP file, or a ZipInfo object.
mode should be ‘r’ to read a file already in the ZIP file, or ‘w’ to write to a file newly added to the archive.
pwd is the password to decrypt files (only used for reading).
When writing, if the file size is not known in advance but may exceed 2 GiB, pass force_zip64 to use the ZIP64 format, which can handle large files. If the size is known in advance, it is best to pass a ZipInfo instance for name, with zinfo.file_size set.
Parameter | Type |
---|---|
name |
|
mode |
|
pwd |
|
force_zip64 |
printdir()
def printdir(
file,
):
Print a table of contents for the zip file.
Parameter | Type |
---|---|
file |
read()
def read(
name,
pwd,
):
Return file bytes for name. ‘pwd’ is the password to decrypt encrypted files.
Parameter | Type |
---|---|
name |
|
pwd |
setpassword()
def setpassword(
pwd,
):
Set default password for encrypted files.
Parameter | Type |
---|---|
pwd |
testzip()
def testzip()
Read all the files and check the CRC.
Return None if all files could be read successfully, or the name of the offending file otherwise.
write()
def write(
filename,
arcname,
compress_type,
compresslevel,
):
Put the bytes from filename into the archive under the name arcname.
Parameter | Type |
---|---|
filename |
|
arcname |
|
compress_type |
|
compresslevel |
writestr()
def writestr(
zinfo_or_arcname,
data,
compress_type,
compresslevel,
):
Write a file into the archive. The contents is ‘data’, which may be either a ‘str’ or a ‘bytes’ instance; if it is a ‘str’, it is encoded as UTF-8 first. ‘zinfo_or_arcname’ is either a ZipInfo instance or the name of the file in the archive.
Parameter | Type |
---|---|
zinfo_or_arcname |
|
data |
|
compress_type |
|
compresslevel |
Properties
Property | Type | Description |
---|---|---|
comment |