| 1 | ''' |
| 2 | restore-mail-inject.py - Tool to inject mails via IMAP |
| 3 | |
| 4 | Copyright (c) 2012 Intra2net AG |
| 5 | Author: Plamen Dimitrov and Thomas Jarosch |
| 6 | |
| 7 | This program is free software: you can redistribute it and/or modify |
| 8 | it under the terms of the GNU General Public License as published by |
| 9 | the Free Software Foundation, either version 3 of the License, or |
| 10 | (at your option) any later version. |
| 11 | |
| 12 | This program is distributed in the hope that it will be useful, |
| 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | GNU General Public License for more details. |
| 16 | ''' |
| 17 | import logging |
| 18 | |
| 19 | class WarningsHandler(logging.Handler): |
| 20 | """This class iterates through the e-mail files.""" |
| 21 | |
| 22 | # class attributes |
| 23 | detected_problems = None |
| 24 | |
| 25 | def __init__(self): |
| 26 | """Initialize a handler to count number of warnings.""" |
| 27 | |
| 28 | logging.Handler.__init__(self) |
| 29 | self.detected_problems = 0 |
| 30 | |
| 31 | def emit(self, record): |
| 32 | """Increase number of warnings found""" |
| 33 | |
| 34 | self.detected_problems += 1 |
| 35 | |