<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,10 +1,10 @@
 #!/usr/bin/env python
-
 import os
 import time
 import commands
 from optparse import OptionParser
 
+
 def mtime_checker(arg, directory_name, file_list):
     &quot;&quot;&quot;
     Check whether a list of files have been modified 
@@ -13,9 +13,25 @@ def mtime_checker(arg, directory_name, file_list):
     &quot;&quot;&quot;
     (mtime, modified_list) = arg
     for f in [os.path.join(directory_name, file) for file in file_list]:
-        if os.path.getmtime(f) &gt; mtime:
-            modified_list.append(f)
+        if not skip_filepath(f):
+            if os.path.isdir(f) and __skip_extensions__:
+                # if extensions are watched, don't bother with directories
+                continue
+            if os.path.getmtime(f) &gt; mtime:
+                modified_list.append(f)
+
 
+def skip_filepath(filepath):
+    &quot;&quot;&quot; return true if the passed filename can be skipped in the change
+    checker. &quot;&quot;&quot;
+    if os.path.basename(filepath).startswith('.#') or \
+      filepath.endswith('~'):
+        # backup file
+        return True
+    
+    if os.path.splitext(filepath)[-1].lower() in __skip_extensions__:
+        return True
+    
 def get_changed_files(path, delta):
     &quot;&quot;&quot;
     Get the list of files that have changed in 
@@ -36,11 +52,17 @@ def run_if_changes(modified_files, command_to_run):
     else:
         return False
 
-def main(path, change_period, command):
+#global __skip_extensions__
+__skip_extensions__ = []
+
+def main(path, change_period, command, skip_extensions):
     &quot;&quot;&quot;
     Long running application which polls for changes
     and when it finds them runs a specified command.
     &quot;&quot;&quot;
+    __skip_extensions__.extend([x.startswith('.') and x or '.'+x 
+                                for x
+                                in skip_extensions.replace(',',' ').split()])
     # keep the script running
     while 1:
         # get a list of files that have changed
@@ -66,10 +88,14 @@ if __name__ == &quot;__main__&quot;:
                         help='time period to wait between checks'),
     parser.add_option('-c', '--command', action='store', dest='command',
                         help='command to execute'),
+    parser.add_option('--skip-extensions', action='store', dest='skip_extensions',
+                      help='extensions to skip (list by space or comma)', 
+                      default=&quot;pyc html css&quot;),
     # parse the command arguments
     (options, args) = parser.parse_args()
     
     if options.command:
-        main(options.path, options.change_period, options.command)
+        main(options.path, int(options.change_period), options.command,
+             options.skip_extensions)
     else:
         print &quot;you must pass a command to execute using the -c flag.&quot;
\ No newline at end of file</diff>
      <filename>localbuilder.py</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>930856c38f220fc8e9f5de5ca954fdfd0604da70</id>
    </parent>
  </parents>
  <author>
    <name>Peter Bengtsson</name>
    <email>peter@fry-it.com</email>
  </author>
  <url>http://github.com/garethr/localbuilder/commit/2bdeaf0ae12d291af0b140d0527831e2a07683f9</url>
  <id>2bdeaf0ae12d291af0b140d0527831e2a07683f9</id>
  <committed-date>2009-01-16T04:03:42-08:00</committed-date>
  <authored-date>2009-01-15T05:50:33-08:00</authored-date>
  <message>Added support for skippable extensions and fixed bug in how change_period is picked up

Signed-off-by: Gareth Rushgrove &lt;gareth@morethanseven.net&gt;</message>
  <tree>0faed36c0601861e39643638e6bf3aa0731f3f0b</tree>
  <committer>
    <name>Gareth Rushgrove</name>
    <email>gareth@morethanseven.net</email>
  </committer>
</commit>
