API Reference

FileIO

Hash

beartools.fileio.hash.hash_file(filepath: Path | str, algorithm: str | Callable = 'sha3_512', size: int = 8388608) str

Hash a file with the specified algorithm

Parameters:
  • filepath – Path to file to hash

  • algorithm – Algorithm to use from hashlib.algorithms_guaranteed, defaults to sha3_512. Can also be a custom function that returns a hashlib-compatible Hash object

  • size – Blocksize for chunking, default 8MB (8388608)

Returns:

Hex string of hash output

Raises:
  • FileNotFoundError

  • ValueError – invalid hash algorithm

Oracle

Factories

beartools.oracle.factories.dict_factory(cursor: Cursor) Callable[[Iterable[Any]], dict[Any, Any]]

Returns a dictionary when querying the database.

Usage:

cursor.rowfactory = dict_factory(cursor)

Parameters:

cursor – Database connection cursor

Returns:

The nested create_row function