Commits

Christopher Nilsson committed 0c23cd6

tabs -> spaces

  • Participants
  • Parent commits 126fa88

Comments (0)

Files changed (4)

File demo/dwexample.py

     paths = [path for path in paths if os.path.exists(path) and os.path.isdir(path)]
 
     if len(paths) == 0:
-	raise ValueError, "Must supply at least one directory path"
+        raise ValueError, "Must supply at least one directory path"
     if action is None:
-	raise ValueError, "Must supply event handler callback"
+        raise ValueError, "Must supply event handler callback"
 
     # Start listening...
     monitor = dirwatch.create_dirwatcher()
     monitor.events.subscribe(EV_FILE_CREATED, action)
     try:
-	for path in paths:
-	    print "Adding watch:", path
-	    monitor.add_watch(path)
-	
-	monitor.start_monitor()  # non-blocking
-	try:
-	    print "Listening (press Ctrl-C to quit)..."
-	    try:
-		# dumb busy wait. 
-		# The monitor itself will happily sit in the
-		# background now, and we could be doing other
-		# things here...
-		while True:
-		    time.sleep(0.5)
-	    except KeyboardInterrupt:
-		print "quitting..."
-	finally:
-	    monitor.stop_monitor()
-
+        for path in paths:
+            print "Adding watch:", path
+            monitor.add_watch(path)
+        
+        monitor.start_monitor()  # non-blocking
+        try:
+            print "Listening (press Ctrl-C to quit)..."
+            try:
+            # dumb busy wait. 
+            # The monitor itself will happily sit in the
+            # background now, and we could be doing other
+            # things here...
+            while True:
+                time.sleep(0.5)
+            except KeyboardInterrupt:
+            print "quitting..."
+        finally:
+            monitor.stop_monitor()
     finally:
-	monitor.events.unsubscribe(EV_FILE_CREATED, action)
+        monitor.events.unsubscribe(EV_FILE_CREATED, action)
 
     print "done."
 
 
     # If the user doesn't specify, we'll default to the current dir.
     if len(args.directories) == 0:
-	args.directories.append(os.getcwd())
+        args.directories.append(os.getcwd())
 
     monitor_directories(args.directories, action=on_new_file)

File dirwatch/base.py

     def _process_incoming_queue(self):
         """ Core event dispatcher.
 
-	Receives filesystem events from the monitor(s), and
-	broadcasts them to interested listeners via the EventManager.
-	"""
+        Receives filesystem events from the monitor(s), and
+        broadcasts them to interested listeners via the EventManager.
+        """
         while self.monitoring:
             event = self.monitor_events.get()
             
         Returns:
             True, if the monitor starts successfully.
 
-	NOTE: This base-class routine simply sets some state, and broadcasts
-	    a eventtype.EV_MONITOR_STARTED message. The descendant classes
-	    are expected to then start whatever monitoring mechanism they have
-	    provided.
-	"""
+        NOTE: This base-class routine simply sets some state, and broadcasts
+            a eventtype.EV_MONITOR_STARTED message. The descendant classes
+            are expected to then start whatever monitoring mechanism they have
+            provided.
+        """
         if not self.monitoring:
             assert self._worker_thread is None
             
     def stop_monitor(self):
         """ Stop the event monitor.
 
-	NOTE: This base-class routine simply resets the state (set by start_monitor),
-	    and broadcasts a eventtype.EV_MONITOR_STOPPED message.
-	    Descendant is expected to cleanly shutdown its monitoring mechanism.
-	"""
+        NOTE: This base-class routine simply resets the state (set by start_monitor),
+            and broadcasts a eventtype.EV_MONITOR_STOPPED message.
+            Descendant is expected to cleanly shutdown its monitoring mechanism.
+        """
         if self.monitoring:
             self.monitor_events.put(self._exit_notification)
             self.monitoring = False
         
         Intension is to be able to find before/after differences, when
         there are too many events to process for our monitor, and we need
-	to refresh our view to catch up.
+        to refresh our view to catch up.
         """
         def _iter_paths():
             for path, subdirs, filenames in os.walk(directory):
                 self.events.notify(eventtype.EV_FILE_DELETED, path=filepath, timestamp=time.time())
         removals = None
         
-        
-        
-                
-            

File dirwatch/eventtype.py

 """ Events supported by the EventManager.
 
     File events:
-	EV_FILE_CREATED,
-	EV_FILE_DATA_CHANGED
-	EV_FILE_DELETED
+    EV_FILE_CREATED,
+    EV_FILE_DATA_CHANGED
+    EV_FILE_DELETED
 
     Monitor events:
-	EV_MONITOR_STARTED
-	EV_MONITOR_STOPPED
-	EV_WATCH_ADDED
+    EV_MONITOR_STARTED
+    EV_MONITOR_STOPPED
+    EV_WATCH_ADDED
 """
 
 
         'Development Status :: 5 - Alpha',
         'Inteded Audience :: Developers',
         'License :: OSI Approved :: MIT License',
-	'Environment :: Win32 (MS Windows)',
-	'Operating System :: Microsoft :: Windows :: Windows NT/2000',
-	'Topic :: System :: Monitoring'
-	'Programming Language :: Python :: 2.7'
+    'Environment :: Win32 (MS Windows)',
+    'Operating System :: Microsoft :: Windows :: Windows NT/2000',
+    'Topic :: System :: Monitoring'
+    'Programming Language :: Python :: 2.7'
     ]
 )