X-Git-Url: https://wannabe.guru.org/gitweb/?a=blobdiff_plain;f=src%2Fpyutils%2Ffiles%2Fdirectory_filter.py;h=d7499a2622960449673f283c9426a20d7d3bb251;hb=993b0992473c12294ed659e52b532e1c8cf9cd1e;hp=3d0522b7feab95d7df25c30bd1dec23b99ae743f;hpb=b38920f24d1ac948958480c540bc4b8436186765;p=pyutils.git diff --git a/src/pyutils/files/directory_filter.py b/src/pyutils/files/directory_filter.py index 3d0522b..d7499a2 100644 --- a/src/pyutils/files/directory_filter.py +++ b/src/pyutils/files/directory_filter.py @@ -2,10 +2,19 @@ # © Copyright 2021-2022, Scott Gasch -"""Two predicates that can help avoid unnecessary disk I/O by -detecting if a particular file is identical to the contents about to -be written or if a particular directory already contains a file that -is identical to the one about to be written. See examples below. +"""This module contains two classes meant to help reduce unnecessary disk +I/O operations: + +The first, :class:`DirectoryFileFilter`, determines when the contents +of a file held in memory are identical to the file copy already on +disk. + +The second, :class:`DirectoryAllFilesFilter`, is basically the same +except for the caller need not indicate the name of the disk file +because it will check the memory file's signature against *all file +signatures* in a particular directory on disk. + +See examples below. """ import hashlib @@ -36,12 +45,10 @@ class DirectoryFileFilter(object): True >>> os.remove(testfile) - """ def __init__(self, directory: str): - """C'tor. - + """ Args: directory: the directory we're filtering accesses to """ @@ -117,11 +124,11 @@ class DirectoryAllFilesFilter(DirectoryFileFilter): directory (regardless of its name). i.e. this is the same as :class:`DirectoryFileFilter` except that - our apply() method will return true not only if the contents to be - written are identical to the contents of filename on the disk but - also it returns true if there exists some other file sitting in - the same directory which already contains those identical - contents. + our :meth:`apply` method will return true not only if the contents + to be written are identical to the contents of filename on the + disk but also it returns true if there exists some other file + sitting in the same directory which already contains those + identical contents. >>> testfile = '/tmp/directory_filter_text_f39e5b58-c260-40da-9448-ad1c3b2a69c3.txt' @@ -143,8 +150,7 @@ class DirectoryAllFilesFilter(DirectoryFileFilter): """ def __init__(self, directory: str): - """C'tor. - + """ Args: directory: the directory we're watching """