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

Revision 3561, 2.6 kB (checked in by jerome, 10 years ago)

Changed copyright years.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1# -*- coding: utf-8 -*-
2#
3# PyKota : Print Quotas for CUPS
4#
5# (c) 2003-2013 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 3 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, see <http://www.gnu.org/licenses/>.
18#
19# $Id$
20#
21#
22
23"""This module defines a class for plain text reporting."""
24
25from pykota.reporter import BaseReporter
26
27class Reporter(BaseReporter) :
28    """Text reporter."""
29    def generateReport(self) :
30        """Produces a simple text report."""
31        self.report = []
32        if self.isgroup :
33            prefix = "Group"
34        else :
35            prefix = "User"
36        for printer in self.printers :
37            self.report.append(self.getPrinterTitle(printer))
38            self.report.append(self.getPrinterGraceDelay(printer))
39            (pjob, ppage) = self.getPrinterPrices(printer)
40            self.report.append(pjob)
41            self.report.append(ppage)
42
43            total = 0
44            totalmoney = 0.0
45            header = self.getReportHeader()
46            self.report.append(header)
47            self.report.append('-' * len(header))
48            for (entry, entrypquota) in getattr(self.tool.storage, "getPrinter%ssAndQuotas" % prefix)(printer, self.ugnames) :
49                (pages, money, name, reached, pagecounter, soft, hard, balance, datelimit, lifepagecounter, lifetimepaid, overcharge, warncount) = self.getQuota(entry, entrypquota)
50                self.report.append("%-15.15s %s %5s %7i %7s %7s %10s %-10.10s %8i %10s %4s" % (name, reached, overcharge, pagecounter, soft, hard, balance, datelimit, lifepagecounter, lifetimepaid, warncount))
51                total += pages
52                totalmoney += money
53
54            if total or totalmoney :
55                (tpage, tmoney) = self.getTotals(total, totalmoney)
56                self.report.append((" " * 62) + tpage + tmoney)
57            self.report.append((" " * 63) + self.getPrinterRealPageCounter(printer))
58            self.report.append("")
59        if self.isgroup :
60            self.report.append(_("Totals may be inaccurate if some users are members of several groups."))
61        return "\n".join(self.report)
Note: See TracBrowser for help on using the browser.