[1144] | 1 | # PyKota |
---|
| 2 | # -*- coding: ISO-8859-15 -*- |
---|
[1048] | 3 | |
---|
| 4 | # PyKota - Print Quotas for CUPS and LPRng |
---|
| 5 | # |
---|
[1257] | 6 | # (c) 2003-2004 Jerome Alet <alet@librelogiciel.com> |
---|
[1048] | 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 | # |
---|
[2054] | 23 | # |
---|
[1048] | 24 | |
---|
| 25 | from pykota.reporter import BaseReporter, PyKotaReporterError |
---|
| 26 | |
---|
| 27 | class Reporter(BaseReporter) : |
---|
[1235] | 28 | """Text reporter.""" |
---|
[1048] | 29 | def generateReport(self) : |
---|
| 30 | """Produces a simple text report.""" |
---|
| 31 | self.report = [] |
---|
[1251] | 32 | if self.isgroup : |
---|
| 33 | prefix = "Group" |
---|
| 34 | else : |
---|
| 35 | prefix = "User" |
---|
[1048] | 36 | for printer in self.printers : |
---|
[1235] | 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 | |
---|
[1048] | 43 | total = 0 |
---|
| 44 | totalmoney = 0.0 |
---|
[1251] | 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) : |
---|
[2054] | 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)) |
---|
[1251] | 51 | total += pages |
---|
| 52 | totalmoney += money |
---|
| 53 | |
---|
[1048] | 54 | if total or totalmoney : |
---|
[1235] | 55 | (tpage, tmoney) = self.getTotals(total, totalmoney) |
---|
[2054] | 56 | self.report.append((" " * 62) + tpage + tmoney) |
---|
| 57 | self.report.append((" " * 63) + self.getPrinterRealPageCounter(printer)) |
---|
[1048] | 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) |
---|
| 62 | |
---|