scdatatools.p4k module¶
- class scdatatools.p4k.P4KExtFile(fileobj, mode, p4kinfo, decrypter=None, close_fileobj=False)[source]¶
Bases:
ZipExtFile
- MIN_READ_SIZE = 65536¶
- class scdatatools.p4k.P4KFile(file, mode='r', key=b'^z \x020.\xeb\x1a;\xb6\x17\xc3\x0f\xde\x1eG', load_monitor=None)[source]¶
Bases:
ZipFile
- close()[source]¶
Close the file, and for mode ‘w’, ‘x’ and ‘a’ write the ending records.
- Return type:
None
- extract(member, *args, **kwargs)[source]¶
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’.
- extractall(path=None, members=None, overwrite=True, save_to=False, converters=None, converter_options=None, ignore_converter_errors=False, monitor=<function _p4k_extract_monitor>)[source]¶
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().
- Parameters:
path – The output directory to extract files to, defaults to the current working directory
members (
Optional
[List
[Union
[P4KInfo
,str
]]]) – List of the members of the P4K to extractoverwrite (
bool
) – Overwrite files that already existsave_to (
bool
) – If true, the members will be extracted without recreating their full path within pathconverters (
Union
[str
,List
[str
],None
]) – List of P4KConverterPlugins to use to convert members as they are extracted. Use ‘auto’ to automatically run all configured converters.converter_options (
Optional
[dict
]) – Dictionary of kwargs to pass to the specified converters, allowing converter specific options to be passedignore_converter_errors (
bool
) – If True errors within converters will be logged, but extraction will continue and the unconverted files will be extractedmonitor (
Callable
) – Callable used to monitor the progress of the. Set to None to disable monitoring. The callable will be passed (info: P4KInfo, cur_index, total_members)
- open(name, mode='r', pwd=None, *, force_zip64=False)[source]¶
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.
- save_to(member, *args, **kwargs)[source]¶
Extract a member into path. This will no recreate the archive directory structure, it will place the extracted file directly into path which must exist. Use extract
- search(file_filters, exclude=None, ignore_case=True, expand_subarchives=False, mode='re')[source]¶
Search the filelist by path
- Parameters:
file_filters (
Union
[list
,tuple
,set
,str
]) –ignore_case (
bool
) – Match string case or notexpand_subarchives (
bool
) – Automatically expand sub-archives and search them as well.exclude (
Optional
[List
[str
]]) – List of filenames that should be excluded from the results. This must be an exact match (although honors ignore_case).mode (
str
) – Method of performing a match. Valid values are: re: File matching glob compiled into a regular expression - re.match(filename) startswith: Uses the string startswith function - if any(filename.startswith(_) for _ in file_filters) endswith: Uses the string startswith function - if any(filename.endswith(_) for _ in file_filters) in: Performs and in check - filename in file_filters in_strip: Performs an in check, but strips the file extension before performing the in check
- Return type:
List
[P4KInfo
]- Returns:
- class scdatatools.p4k.P4KInfo(filename, date_time=(1980, 1, 1, 0, 0, 0), p4k=None, subinfo=None, archive=None)[source]¶
Bases:
ZipInfo
- CRC¶
- comment¶
- compress_size¶
- compress_type¶
- create_system¶
- create_version¶
- date_time¶
- external_attr¶
- extra¶
- extract_version¶
- file_size¶
- filename¶
- flag_bits¶
- header_offset¶
- internal_attr¶
- orig_filename¶
- reserved¶
- volume¶
- class scdatatools.p4k.Pak(file, mode='r', compression=0, allowZip64=True, compresslevel=None, *, strict_timestamps=True)[source]¶
Bases:
_ZipFileWithFlexibleFilenames