briancurtin  committed bc75ccf

Rename path to be directory

  • Participants
  • Parent commits ba45218

Comments (0)

Files changed (1)


 class FileSystemWatcher(object):
-    def __init__(self, path, filter="*.*"):
+    def __init__(self, directory, filter="*.*"):
         """path: The directory to monitor.
            filter: The type of files to watch.
         To monitor one specific file, specify `path` as the parent
         directory and `filter` as the exact file name."""
-        if os.path.exists(path) and os.path.isdir(path): 
-            self._path = path
+        if os.path.exists(directory) and os.path.isdir(directory):
+            self._directory = directory
-            raise ValueError("path is not a valid directory")
+            raise ValueError("{} must be a directory".format(directory))
         self._filter = filter
         self._watcher = _watcher.Watcher(self._path, self._callback)
     def Filter(self, value):
+        if not os.path.isdir(value):
+            raise ValueError("{} must be a directory".format(value))
         self._filter = value
     def Path(self):
-        return self._path
+        return self._directory
     def Path(self, value):
-        self._path = value
+        self._directory = value
     def _callback(self, action, path):
         """Called from Watcher with an action value and relative path.
                 update = FileSystemEventArgs()
                 update = RenamedEventArgs()
-                update.OldFullPath = os.path.join(self._path, self._old_name)
+                update.OldFullPath = os.path.join(self._directory,
+                                                  self._old_name)
                 update.OldName = os.path.basename(self._old_name)
             update.ChangeType = action
-            update.FullPath = os.path.join(self._path, path)
+            update.FullPath = os.path.join(self._directory, path)
             update.Name = os.path.basename(path)
             for cb in callbacks.values():