Skip to content

Commit

Permalink
Minor formatting changes
Browse files Browse the repository at this point in the history
  • Loading branch information
joh committed Sep 15, 2013
1 parent 7c8b961 commit be471e7
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions whenchanged/whenchanged.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,6 @@
import re
import pyinotify

usage = 'Usage: %(prog)s [-r] FILE COMMAND...'
usage += '\n %(prog)s [-r] FILE [FILE ...] -c COMMAND...'
description = 'Run a command when a file is changed.\n'
description += 'FILE can be a directory. Watch recursively with -r.\n'
description += 'Use %f to pass the filename to the command.\n'

def print_usage(prog):
print usage % {'prog': prog}

def print_help(prog):
print_usage(prog)
print "\n" + description

class WhenChanged(pyinotify.ProcessEvent):
# Exclude Vim swap files, its file creation test file 4913 and backup files
exclude = re.compile(r'^\..*\.sw[px]*$|^4913$|.~$')
Expand Down Expand Up @@ -73,7 +60,7 @@ def run(self):
mask = pyinotify.IN_CLOSE_WRITE | pyinotify.IN_CREATE
watched = set()
for p in self.paths:
if os.path.isdir(p) and p not in watched:
if os.path.isdir(p) and not p in watched:
# Add directory
wdd = wm.add_watch(p, mask, rec=self.recursive, auto_add=self.recursive)
else:
Expand All @@ -85,6 +72,19 @@ def run(self):
notifier.loop()


usage = 'Usage: %(prog)s [-r] FILE COMMAND...\n'
usage += ' %(prog)s [-r] FILE [FILE ...] -c COMMAND...'
description = 'Run a command when a file is changed.\n'
description += 'FILE can be a directory. Watch recursively with -r.\n'
description += 'Use %f to pass the filename to the command.\n'

def print_usage(prog):
print usage % {'prog': prog}

def print_help(prog):
print_usage(prog)
print "\n" + description

def main():
args = sys.argv
prog = args.pop(0)
Expand Down

0 comments on commit be471e7

Please sign in to comment.