__getitem__#

barecat.Barecat.__getitem__(path)#

Get the contents of a file in the Barecat archive.

Parameters:

path (str) – Path to the file within the archive.

Returns:

The contents of the file. Either raw bytes, or decoded based on the file extension, if auto_codec was True in the constructor, or if codecs have been registered for the file extension via register_codec.

Raises:

KeyError – If a file with this path does not exist in the archive.

Return type:

Union[bytes, Any]

Examples

>>> bc = Barecat('test.barecat', readonly=False)
>>> bc['file.txt'] = b'Hello, world!'
>>> bc['file.txt']
b'Hello, world!'