Skip to content

Commit

Permalink
Merge pull request joh#18 from chris-martin/move_to
Browse files Browse the repository at this point in the history
Also listen for move_to events
  • Loading branch information
joh committed May 6, 2014
2 parents 6237b00 + 3559885 commit 9dee022
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions whenchanged/whenchanged.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,25 @@ def is_interested(self, path):

return False

def process_IN_CLOSE_WRITE(self, event):
path = event.pathname
def on_change(self, path):
if self.is_interested(path):
self.run_command(path)

def process_IN_CLOSE_WRITE(self, event):
self.on_change(event.pathname)

def process_IN_MOVED_TO(self, event):
self.on_change(event.pathname)

def run(self):
wm = pyinotify.WatchManager()
notifier = pyinotify.Notifier(wm, self)

# Add watches (IN_CREATE is required for auto_add)
mask = pyinotify.IN_CLOSE_WRITE | pyinotify.IN_CREATE
mask = (pyinotify.IN_CLOSE_WRITE |
pyinotify.IN_MOVED_TO |
pyinotify.IN_CREATE)

watched = set()
for p in self.paths:
if os.path.isdir(p) and not p in watched:
Expand Down

0 comments on commit 9dee022

Please sign in to comment.