datalad_next.iter_collections.zipfile
Report on the content of ZIP file
The main functionality is provided by the iter_zip() function.
- class datalad_next.iter_collections.zipfile.ZipfileItem(type: 'FileSystemItemType', name: 'str', size: 'int', mtime: 'float | None' = None, mode: 'int | None' = None, uid: 'int | None' = None, gid: 'int | None' = None, link_target: 'Any | None' = None, fp: 'IO | None' = None)[source]
Bases:
FileSystemItem- name: str
- property path: PurePosixPath
Returns the item name as a
PurePosixPathinstanceZIP uses POSIX paths as item identifiers from version 6.3.3 onwards. Not all POSIX paths are legal paths on non-POSIX file systems or platforms. Therefore we cannot use a platform-dependent
PurePath-instance to address ZIP-file items, anq we usePurePosixPath-instances instead.
- datalad_next.iter_collections.zipfile.iter_zip(path: Path, *, fp: bool = False) Generator[ZipfileItem, None, None][source]
Uses the standard library
zipfilemodule to report on ZIP-filesA ZIP archive can represent more or less the full bandwidth of file system properties, therefore reporting on archive members is implemented similar to
iter_dir(). The iterator produces anZipfileIteminstance with standard information on file system elements, such assize, ormtime.- Parameters:
path (Path) -- Path of the ZIP archive to report content for (iterate over).
fp (bool, optional) -- If
True, each file-type item includes a file-like object to access the file's content. This file handle will be closed automatically when the next item is yielded or the function returns.
- Yields:
ZipfileItem-- Thenameattribute of an item is astrwith the corresponding archive member name (in POSIX conventions).