Core

chicky.core.checksum(filepath, digest_size=20)[source]

Checksum a file in an efficient way for large files with blake2b.

Borrowed from: https://stackoverflow.com/a/44873382

Parameters:

filepath (pathlib.Path) – File path to open and checksum.

Keyword Arguments:

digest_size (integer) – Maximum size of hash digest. This is the size of hash in bytes, the returned string will be longer since it is the hexadecimal digest. Commonly if you want a string of 10 characters you should ask for a digest of 20.

Returns:

The file checksum.

Return type:

string

chicky.core.collect_files(dirpath, extensions=None, dir_leads=None, filename_leads=None)[source]

Recursively collect every file from a directory and compute their checksum.

Parameters:

dirpath (string or pathlib.Path)

Keyword Arguments:
  • extensions (list) – List of allowed file extensions. When it is not empty, each that does not match any of those extensions will be ignored.

  • dir_leads (list) – A list of leading patterns to check on paths, each path starting with one of those patterns will be ignored. Match is performed against the relative file path (from the dirpath).

  • filename_leads (list) – A list of leading patterns to check on filenames, each filename starting with one of those patterns will be ignored.

Returns:

Yield tuples of path + checksum string

Return type:

Generator

chicky.core.formatter(files, args)[source]

Format file data.

Parameters:

args (object)

Return type:

string