[1048] | 1 | # PyKota |
---|
| 2 | # |
---|
| 3 | # PyKota : Print Quotas for CUPS and LPRng |
---|
| 4 | # |
---|
| 5 | # (c) 2003 Jerome Alet <alet@librelogiciel.com> |
---|
| 6 | # This program is free software; you can redistribute it and/or modify |
---|
| 7 | # it under the terms of the GNU General Public License as published by |
---|
| 8 | # the Free Software Foundation; either version 2 of the License, or |
---|
| 9 | # (at your option) any later version. |
---|
| 10 | # |
---|
| 11 | # This program is distributed in the hope that it will be useful, |
---|
| 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 14 | # GNU General Public License for more details. |
---|
| 15 | # |
---|
| 16 | # You should have received a copy of the GNU General Public License |
---|
| 17 | # along with this program; if not, write to the Free Software |
---|
| 18 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. |
---|
| 19 | # |
---|
| 20 | # $Id$ |
---|
| 21 | # |
---|
| 22 | # $Log$ |
---|
| 23 | # Revision 1.1 2003/06/30 12:46:15 jalet |
---|
| 24 | # Extracted reporting code. |
---|
| 25 | # |
---|
| 26 | # |
---|
| 27 | # |
---|
| 28 | |
---|
| 29 | class PyKotaReporterError(Exception): |
---|
| 30 | """An exception for Reporter related stuff.""" |
---|
| 31 | def __init__(self, message = ""): |
---|
| 32 | self.message = message |
---|
| 33 | Exception.__init__(self, message) |
---|
| 34 | def __repr__(self): |
---|
| 35 | return self.message |
---|
| 36 | __str__ = __repr__ |
---|
| 37 | |
---|
| 38 | class BaseReporter : |
---|
| 39 | """Base class for all reports.""" |
---|
| 40 | def __init__(self, tool, printers, ugnames, isgroup) : |
---|
| 41 | """Initialize local datas.""" |
---|
| 42 | self.tool = tool |
---|
| 43 | self.printers = printers |
---|
| 44 | self.ugnames = ugnames |
---|
| 45 | self.isgroup = isgroup |
---|
| 46 | |
---|
| 47 | def openReporter(tool, reporttype, printers, ugnames, isgroup) : |
---|
| 48 | """Returns a reporter instance of the proper reporter.""" |
---|
| 49 | try : |
---|
| 50 | exec "from pykota.reporters import %s as reporterbackend" % reporttype.lower() |
---|
| 51 | except ImportError : |
---|
| 52 | raise PyKotaReporterError, _("Unsupported reporter backend %s") % reporttype |
---|
| 53 | else : |
---|
| 54 | return getattr(reporterbackend, "Reporter")(tool, printers, ugnames, isgroup) |
---|