import os
from typing import Any, Optional
-import predicate
-import file_utils
-
-class DirectoryFileFilter(predicate.Predicate):
- """A predicate that will return False if when a proposed file's
+class DirectoryFileFilter(object):
+ """A predicate that will return False if / when a proposed file's
content to-be-written is identical to the contents of the file;
skip the write.
"""
-
def __init__(self, directory: str):
super().__init__()
+ import file_utils
if not file_utils.does_directory_exist(directory):
raise ValueError(directory)
self.directory = directory
self._update_file(path, mtime)
def _update_file(self, filename: str, mtime: Optional[float] = None):
+ import file_utils
assert file_utils.does_file_exist(filename)
if mtime is None:
mtime = file_utils.get_file_raw_mtime(filename)
print(self.all_md5s)
def _update_file(self, filename: str, mtime: Optional[float] = None):
+ import file_utils
assert file_utils.does_file_exist(filename)
if mtime is None:
mtime = file_utils.get_file_raw_mtime(filename)
mem_hash.update(item)
md5 = mem_hash.hexdigest()
return md5 not in self.all_md5s
-