bp_text.utilities
This module implements utility functions.
Created: 2025-03-28 Author: Ruben Philipp <me@rubenphilipp.com>
$$ Last modified: 20:45:06 Wed Apr 23 2025 CEST
Functions
|
This function creates a checksum for a file. |
|
Read a serialized (pickled) file and return the data it holds. |
|
This function serializes (pickles) an object and stores it in a file given as file_path. |
- bp_text.utilities.file_checksum(file_path, algorithm='sha256', chunk_size=8192)[source]
This function creates a checksum for a file.
- Parameters:
file_path (string) – Path to the file to be checksummed.
algorithm (string) – The hash algorithm (e.g. “sha256”, “md5”, “sha1”). Default = “sha256”
chunk_size (integer) – The chunk size for checksum creation in Bytes. Default = 8192
- bp_text.utilities.read_pickle(file_path)[source]
Read a serialized (pickled) file and return the data it holds.
- Parameters:
file_path (string) – The path to the serialized data.
- bp_text.utilities.write_pickle(obj, file_path, protocol=5)[source]
This function serializes (pickles) an object and stores it in a file given as file_path.
- Parameters:
file_path (string) – The path where to store the pickle file. It is recommended to use the .pickle suffix.
protocol (integer) – The pickle protocol. Default = pickle.HIGHEST_PROTOCOL