root / pykota / trunk / pykota / reporters / text.py @ 1257

Revision 1257, 3.6 kB (checked in by jalet, 20 years ago)

Copyright year changed.

  • 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-2004 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.9  2004/01/08 14:10:33  jalet
25# Copyright year changed.
26#
27# Revision 1.8  2004/01/06 15:51:46  jalet
28# Code factorization
29#
30# Revision 1.7  2003/12/27 16:49:25  uid67467
31# Should be ok now.
32#
33# Revision 1.6  2003/12/02 14:40:21  jalet
34# Some code refactoring.
35# New HTML reporter added, which is now used in the CGI script for web based
36# print quota reports. It will need some de-uglyfication though...
37#
38# Revision 1.5  2003/10/07 09:07:29  jalet
39# Character encoding added to please latest version of Python
40#
41# Revision 1.4  2003/07/07 11:49:24  jalet
42# Lots of small fixes with the help of PyChecker
43#
44# Revision 1.3  2003/07/05 07:46:50  jalet
45# The previous bug fix was incomplete.
46#
47# Revision 1.2  2003/07/02 09:29:12  jalet
48# Bug fixed when wanting a report and an user/group was limited by account balance
49#
50# Revision 1.1  2003/06/30 12:46:15  jalet
51# Extracted reporting code.
52#
53#
54#
55
56from pykota.reporter import BaseReporter, PyKotaReporterError
57   
58class Reporter(BaseReporter) :   
59    """Text reporter."""
60    def generateReport(self) :
61        """Produces a simple text report."""
62        self.report = []
63        if self.isgroup :
64            prefix = "Group"
65        else :   
66            prefix = "User"
67        for printer in self.printers :
68            self.report.append(self.getPrinterTitle(printer))
69            self.report.append(self.getPrinterGraceDelay(printer))
70            (pjob, ppage) = self.getPrinterPrices(printer)
71            self.report.append(pjob)
72            self.report.append(ppage)
73           
74            total = 0
75            totalmoney = 0.0
76            header = self.getReportHeader()
77            self.report.append(header)
78            self.report.append('-' * len(header))
79            for (entry, entrypquota) in getattr(self.tool.storage, "getPrinter%ssAndQuotas" % prefix)(printer, self.ugnames) :
80                (pages, money, name, reached, pagecounter, soft, hard, balance, datelimit, lifepagecounter, lifetimepaid) = self.getQuota(entry, entrypquota)
81                self.report.append("%-9.9s %s %7i %7s %7s %10s %-10.10s %8i %10s" % (name, reached, pagecounter, soft, hard, balance, datelimit, lifepagecounter, lifetimepaid))
82                total += pages
83                totalmoney += money
84               
85            if total or totalmoney :       
86                (tpage, tmoney) = self.getTotals(total, totalmoney)
87                self.report.append((" " * 50) + tpage + tmoney)
88            self.report.append((" " * 51) + self.getPrinterRealPageCounter(printer))
89            self.report.append("")       
90        if self.isgroup :   
91            self.report.append(_("Totals may be inaccurate if some users are members of several groups."))
92        return "\n".join(self.report)   
93                       
Note: See TracBrowser for help on using the browser.