Add licencing, README and file hierarchy
[imap-mark-seen] / src / warnings_handler.py
diff --git a/src/warnings_handler.py b/src/warnings_handler.py
new file mode 100644 (file)
index 0000000..1ab8a09
--- /dev/null
@@ -0,0 +1,33 @@
+'''
+imap-mark-seen.py - Tool to mark all e-mails as seen
+
+Copyright (c) 2012 Intra2net AG
+Author: Plamen Dimitrov and Thomas Jarosch
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+'''
+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