root / pykota / trunk / pykota / reporter.py @ 1144

Revision 1144, 2.0 kB (checked in by jalet, 21 years ago)

Character encoding added to please latest version of Python

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1# PyKota
2# -*- coding: ISO-8859-15 -*-
3#
4# PyKota : Print Quotas for CUPS and LPRng
5#
6# (c) 2003 Jerome Alet <alet@librelogiciel.com>
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 2 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# You should have received a copy of the GNU General Public License
18# along with this program; if not, write to the Free Software
19# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
20#
21# $Id$
22#
23# $Log$
24# Revision 1.2  2003/10/07 09:07:28  jalet
25# Character encoding added to please latest version of Python
26#
27# Revision 1.1  2003/06/30 12:46:15  jalet
28# Extracted reporting code.
29#
30#
31#
32
33class PyKotaReporterError(Exception):
34    """An exception for Reporter related stuff."""
35    def __init__(self, message = ""):
36        self.message = message
37        Exception.__init__(self, message)
38    def __repr__(self):
39        return self.message
40    __str__ = __repr__
41   
42class BaseReporter :   
43    """Base class for all reports."""
44    def __init__(self, tool, printers, ugnames, isgroup) :
45        """Initialize local datas."""
46        self.tool = tool
47        self.printers = printers
48        self.ugnames = ugnames
49        self.isgroup = isgroup
50       
51def openReporter(tool, reporttype, printers, ugnames, isgroup) :
52    """Returns a reporter instance of the proper reporter."""
53    try :
54        exec "from pykota.reporters import %s as reporterbackend" % reporttype.lower()   
55    except ImportError :
56        raise PyKotaReporterError, _("Unsupported reporter backend %s") % reporttype
57    else :   
58        return getattr(reporterbackend, "Reporter")(tool, printers, ugnames, isgroup)
Note: See TracBrowser for help on using the browser.