Make smart futures avoid polling.
[python_utils.git] / directory_filter.py
index 8bced6008cfe6a24e410063a92212e77996c2b10..d14dce7c6eec912e2b2c5b07ebe9b6ef4dfcf716 100644 (file)
@@ -4,17 +4,15 @@ import hashlib
 import os
 from typing import Any, Optional
 
-import file_utils
-
 
 class DirectoryFileFilter(object):
-    """A predicate that will return False if when a proposed file's
+    """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
@@ -30,6 +28,7 @@ class DirectoryFileFilter(object):
                 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)
@@ -59,6 +58,7 @@ class DirectoryAllFilesFilter(DirectoryFileFilter):
         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)