pydoit_nb.checklist#
Checklist file generation
CHECKLIST_FNAME_DEFAULT#
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 filefilename (
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 checkchecklist_file_name – If the filename matches this value, it will be considered a checklist file.
- Returns:
bool–Trueif the file is a checklist file, otherwiseFalse
create_md5_dict#
- create_md5_dict(files, exclusions=None)[source]#
Create dictionary of MD5 hashes for files
- Parameters:
files (
collections.abc.Iterable[pathlib.Path]) – Files to create hashes forexclusions (
typing.Optional[collections.abc.Iterable[collections.abc.Callable[[pathlib.Path],bool]]]) – An iterable of callables. These are applied to each file. If any of the results isTruethen the file is skipped and will not be included in the dictionary of calculated hashes.
- 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 infiles) 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:
directory (
pathlib.Path) – Directory containing arbitary files (we haven’t tested this on any file but any directory containing hashable data files is the intended target)checklist_file (
typing.Optional[pathlib.Path]) – Where to write the checklist file. If not supplied, the result of get_checklist_file(directory) is used.exclusions (
collections.abc.Iterable[collections.abc.Callable[[pathlib.Path],bool]]) – Functions used to check if a file should be excluded or not.
- Returns:
pathlib.Path– Path of the generated checklist file- Raises:
NotADirectoryError – If
directorydoesn’t exist or isn’t a directory