pydoit_nb.checklist#

Checklist file generation

CHECKLIST_FNAME_DEFAULT#

CHECKLIST_FNAME_DEFAULT: str = 'checklist.chk'#

Default name used for checklist files

get_checklist_file#

get_checklist_file(directory, filename='checklist.chk')[source]#

Get the full file path for a checklist

Parameters:
  • directory (pathlib.Path) – Directory for which we want to get the checklist file

  • filename (str) – Name of the checklist file

Returns:

pathlib.Path – Path of the checklist file

is_checklist_file#

is_checklist_file(fp, checklist_filename='checklist.chk')[source]#

Check if a file is a checklist file

Parameters:
  • fp (pathlib.Path) – The file to check

  • checklist_file_name – If the filename matches this value, it will be considered a checklist file.

Returns:

boolTrue if the file is a checklist file, otherwise False

create_md5_dict#

create_md5_dict(files, exclusions=None)[source]#

Create dictionary of MD5 hashes for files

Parameters:
Returns:

dict[pathlib.Path, str] – Dictionary of MD5 hashes for each file which was not excluded. The keys are the file paths (as they appear in files) and the values are the calculated MD5 hashes.

generate_directory_checklist#

generate_directory_checklist(directory, checklist_file=None, exclusions=(<function is_checklist_file>, ))[source]#

Create a checklist file with checksums for all files in a directory

Running this command multiple times should result in the same result. This enables the checklist to be used as a target for doit tasks.

The resulting checklist file can also be used to verify the contents of a folder using the program mdfsum so can be included in any distributed results.

md5sum -c checklist.chk
Parameters:
Returns:

pathlib.Path – Path of the generated checklist file

Raises:

NotADirectoryError – If directory doesn’t exist or isn’t a directory