walk#
- barecat.Barecat.walk(path)[source]#
Recursively list all files and directories in the tree starting from a directory.
This is analogous to Python’s
os.walk().- Parameters:
path (str) – Path to the directory within the archive.
- Returns:
Iterator over (dirpath, dirnames, filenames) tuples, where
dirpathis the path to the directory,dirnamesis a list of all subdirectory names, andfilenamesis a list of all filenames in the directory.- Return type:
Examples
>>> bc = Barecat('test.barecat', readonly=False) >>> bc['dir/file.txt'] = b'Hello, world!' >>> bc['dir/subdir/file2.txt'] = b'Hello, world2!' >>> for dirpath, dirnames, filenames in bc.walk('dir'): ... print(dirpath, dirnames, filenames) dir ['subdir'] ['file.txt'] dir/subdir [] ['file2.txt']