]> git.llucax.com Git - software/pymin.git/blobdiff - pymin/dispatcher.py
Add support for a simple timer to do periodic tasks.
[software/pymin.git] / pymin / dispatcher.py
index 17075a3f1dfec8617432dd68fb532022f7299b2b..24f0d1f14e6a52b6f97fd49664d767b07382a99a 100644 (file)
@@ -216,6 +216,17 @@ class Handler:
             raise HelpNotFoundError(command)
         return handler.handler_help
 
+    def handle_timer(self):
+        r"""handle_timer() -> None :: Do periodic tasks.
+
+        By default we do nothing but calling handle_timer() on subhandlers.
+        """
+        for a in dir(self):
+            if a == 'parent': continue # Skip parents in SubHandlers
+            h = getattr(self, a)
+            if isinstance(h, Handler):
+                h.handle_timer()
+
 def parse_command(command):
     r"""parse_command(command) -> (args, kwargs) :: Parse a command.