mt.base.zipfile

Utilities dealing with a zip file.

Functions

mt.base.zipfile.extract_temporarily(zipfile, out_dirpath=None)

Extracts a zip file to an local dirpath, deleting the dirpath after use.

Parameters:
  • zipfile (str or zipfile.ZipFile) – an open ZipFile instance or a local path to a zip file

  • out_dirpath (str, optional) – If specified, a path to hold all the extracted zip files. Otherwise, a temporary directory is generated.

Returns:

the extracted folder wrapped in an object for use in a with statement. The folder is removed upon exitting the with statement.

Return type:

ExtractedFolder

Classes

  • ExtractedFolder: A scope for use in a with statement. Upon exiting, the extracted folder is removed.

class mt.base.zipfile.ExtractedFolder(dirpath)

A scope for use in a with statement. Upon exiting, the extracted folder is removed.

The ‘dirpath’ attribute of the with object contains the extracted dirpath.

Inheritance

digraph inheritance2726936593 { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "ExtractedFolder" [URL="#mt.base.zipfile.ExtractedFolder",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="A scope for use in a with statement. Upon exiting, the extracted folder is removed."]; }