__setitem__#
- barecat.Barecat.__setitem__(path, content)[source]#
Add a file to the Barecat archive.
- Parameters:
path (str) – Path to the file within the archive.
content (Union[bytes, Any]) – Contents of the file. Either raw bytes, or an object to be encoded based on the file extension, if
auto_codecwas True in the constructor, or if codecs have been registered for the file extension viaregister_codec().
- Raises:
ValueError – If the archive is read-only.
FileExistsBarecatError – If a file or directory with the given path already exists in the archive.
Examples
>>> bc = Barecat('test.barecat', readonly=False) >>> bc['file.txt'] = b'Hello, world!' >>> bc['file.txt'] b'Hello, world!'