glob#

barecat.Barecat.glob(pattern, recursive=False, include_hidden=False)[source]#

Find all files and directories matching a Unix-like glob pattern.

This function is equivalent to Python’s glob.glob().

Parameters:
  • pattern (str) – Unix-like glob pattern to match.

  • recursive (bool) – If True, search recursively, with '/**/' matching any number of directories.

  • include_hidden (bool) – If True, include hidden files and directories (starting with ".").

Returns:

List of all file and directory paths matching the pattern.

Return type:

list[str]

Examples

>>> bc = Barecat('test.barecat', readonly=False)
>>> bc['dir/file.txt'] = b'Hello, world!'
>>> bc['dir/subdir/file2.txt'] = b'Hello, world2!'
>>> bc.glob('dir/**/*.txt', recursive=True)
['dir/file.txt', 'dir/subdir/file2.txt']