class documentation

A pathlib-compatible interface for zip files. Consider a zip file with this structure:: . ├── a.txt └── b ├── c.txt └── d └── e.txt >>> data = io.BytesIO() >>> zf = zipfile.ZipFile(data, 'w') >>> zf.writestr('a.txt', 'content of a') >>> zf.writestr('b/c.txt', 'content of c') >>> zf.writestr('b/d/e.txt', 'content of e') >>> zf.filename = 'mem/abcde.zip' Path accepts the zipfile object itself or a filename >>> root = Path(zf) From there, several path operations are available. Directory iteration (including the zip file itself): >>> a, b = root.iterdir() >>> a Path('mem/abcde.zip', 'a.txt') >>> b Path('mem/abcde.zip', 'b/') name property: >>> b.name 'b' join with divide operator: >>> c = b / 'c.txt' >>> c Path('mem/abcde.zip', 'b/c.txt') >>> c.name 'c.txt' Read text: >>> c.read_text() 'content of c' existence: >>> c.exists() True >>> (b / 'missing.txt').exists() False Coercion to string: >>> import os >>> str(c).replace(os.sep, posixpath.sep) 'mem/abcde.zip/b/c.txt' At the root, ``name``, ``filename``, and ``parent`` resolve to the zipfile. Note these attributes are not valid and will raise a ``ValueError`` if the zipfile has no filename. >>> root.name 'abcde.zip' >>> str(root.filename).replace(os.sep, posixpath.sep) 'mem/abcde.zip' >>> str(root.parent) 'mem'

Method __init__ Construct a Path from a ZipFile or filename.
Method __repr__ Undocumented
Method __str__ Undocumented
Method exists Undocumented
Method is_dir Undocumented
Method is_file Undocumented
Method iterdir Undocumented
Method joinpath Undocumented
Method open Open this entry as text or binary following the semantics of ``pathlib.Path.open()`` by passing arguments through to io.TextIOWrapper().
Method read_bytes Undocumented
Method read_text Undocumented
Instance Variable at Undocumented
Instance Variable root Undocumented
Property filename Undocumented
Property name Undocumented
Property parent Undocumented
Property stem Undocumented
Property suffix Undocumented
Property suffixes Undocumented
Method _is_child Undocumented
Method _next Undocumented
Class Variable __repr Undocumented
def __init__(self, root, at=''): (source)

Construct a Path from a ZipFile or filename. Note: When the source is an existing ZipFile object, its type (__class__) will be mutated to a specialized type. If the caller wishes to retain the original type, the caller should either create a separate ZipFile object or pass a filename.

def __repr__(self): (source)

Undocumented

def __str__(self): (source)

Undocumented

def exists(self): (source)

Undocumented

def is_dir(self): (source)

Undocumented

def is_file(self): (source)

Undocumented

def iterdir(self): (source)

Undocumented

def joinpath(self, *other): (source)

Undocumented

def open(self, mode='r', *args, pwd=None, **kwargs): (source)

Open this entry as text or binary following the semantics of ``pathlib.Path.open()`` by passing arguments through to io.TextIOWrapper().

def read_bytes(self): (source)

Undocumented

def read_text(self, *args, **kwargs): (source)

Undocumented

Undocumented

Undocumented

Undocumented

Undocumented

Undocumented

Undocumented

Undocumented

Undocumented

def _is_child(self, path): (source)

Undocumented

def _next(self, at): (source)

Undocumented

Undocumented