add_by_path#

barecat.Barecat.add_by_path(filesys_path, store_path=None, dir_exist_ok=False)[source]#

Add a file or directory from the filesystem to the archive.

Parameters:
  • filesys_path (str) – Path to the file or directory on the filesystem.

  • store_path (Optional[str]) – Path to store the file or directory in the archive. If None, the same path is used as filesys_path.

  • dir_exist_ok (bool) – If True, do not raise an error when adding a directory and that directory already exists in the archive (as a directory).

Raises:
  • ValueError – If the file is larger than the shard size limit.

  • FileExistsBarecatError – If a file or directory with the same path already exists in the archive, unless dir_exist_ok is True and the item is a directory.

Examples

>>> bc = Barecat('test.barecat', readonly=False)
>>> bc.add_by_path('file.txt')
>>> bc.add_by_path('dir', store_path='dir2')