Added main function exit code which is the number of warnings during script execution
[imap-restore-mail] / warnings_handler.py
diff --git a/warnings_handler.py b/warnings_handler.py
new file mode 100644 (file)
index 0000000..bc6af31
--- /dev/null
@@ -0,0 +1,22 @@
+'''
+restore-mail-inject.py - Tool to inject mails via IMAP
+
+Copyright (c) 2012 Intra2net AG
+'''
+import logging
+
+class WarningsHandler(logging.Handler):
+    """This class iterates through the e-mail files."""
+
+    # class attributes
+    detected_problems = None
+
+    def __init__(self):
+        """Initialize a handler to count number of warnings."""
+        logging.Handler.__init__(self)
+        self.detected_problems = 0
+
+    def emit(self, record):
+        """Increase number of warnings found"""
+        self.detected_problems += 1
+        
\ No newline at end of file