API Reference¶
This document is for developers of furtive, it contains the API functions
Furtive Class¶
Furtive - File Integrity Verification System
-
class
furtive.
Furtive
(base_dir, manifest_path)[source]¶ Bases:
object
Furtive is an application which stores file state and allows users to verify the state in the future. Example use cases include file archives and file transport.
Parameters: - base_dir (str) – Base directory to use for the manifest. Can be a full or relative path.
- manifest_path (str) – Path to the manifest file. Can be a full or relative path.
Sub-Modules¶
Hasher¶
Manages the hashing of files
-
class
furtive.hasher.
HashDirectory
(directory)[source]¶ Bases:
object
Object to manage hashing files in a directory.
This object is responsible for walking the directory tree and adding each file to a list. Once the directory walk has compelted, each file path is passed to hash_task(). After each file has been hashed, this object will then create a Python dictionary of files with their associated hash.
Parameters: directory (str) – Path to directory containing files Returns: Dictionary of file:hash Return type: dict
-
furtive.hasher.
hash_task
(file_path, hash_algorithm='md5')[source]¶ Responsible for hashing a file.
This function reads in the file
file_path
in small chuncks the size of the hash algorithm’s block size in order to avoid running out of memory. This means that this function should be able to read any file irregardless of the size.Parameters: - file_path (str) – path of file to hash
- hash_algorithm (str) – the hashing algorithm to use. All options available in hashlib.algorithms should work. See: https://docs.python.org/2/library/hashlib.html
Returns: hash of file
Return type: dict
Manifest¶
Manifest of files and their hashes
-
class
furtive.manifest.
Manifest
(directory, manifest_file)[source]¶ Bases:
object
Manifest of files and the associated hashes.
Parameters: - directory – directory which will serve as the root for the manifest. All files under the directory will be hashed and added to or compared with the manifest.
- type – str
- manifest_file – file location of the manifest file. This is the
path which will be used for the
create()
andcompare()
methods. If the file exists, thecreate()
method will overwrite it.
-
create
()[source]¶ Creates a new manifest from the directory by calling furtive.hasher.HashDirectory() and placing the return dictionary in to Manifest.manifest.
-
is_empty
()[source]¶ Determines if the manifest within memory is empty.
This simply checks to see if the manifest is None.
Returns: True if manifest is empty, False otherwise. Return type: bool