Index: /pykota/trunk/pykota/progressbar.py
===================================================================
--- /pykota/trunk/pykota/progressbar.py (revision 3434)
+++ /pykota/trunk/pykota/progressbar.py (revision 3434)
@@ -0,0 +1,74 @@
+# -*- coding: utf-8 -*-*-
+#
+# PyKota : Print Quotas for CUPS
+#
+# (c) 2003, 2004, 2005, 2006, 2007, 2008 Jerome Alet <alet@librelogiciel.com>
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+# $Id$
+#
+#
+
+"""This module defines classes to display progress reports."""
+
+import sys
+import time
+
+class Percent :
+    """A class to display progress."""
+    def __init__(self, app, size=None) :
+        """Initializes the engine."""
+        self.isatty = sys.stdout.isatty()
+        self.app = app
+        self.size = None
+        if size :
+            self.setSize(size)
+        self.previous = None
+        self.before = time.time()
+
+    def setSize(self, size) :
+        """Sets the total size."""
+        self.number = 0
+        self.size = size
+        if size :
+            self.factor = 100.0 / float(size)
+
+    def display(self, msg) :
+        """Displays the value."""
+        if self.isatty :
+            self.app.display(msg)
+            sys.stdout.flush()
+
+    def oneMore(self) :
+        """Increments internal counter."""
+        if self.size :
+            self.number += 1
+            percent = "%.02f" % (float(self.number) * self.factor)
+            if percent != self.previous : # optimize for large number of items
+                self.display("\r%s%%" % percent)
+                self.previous = percent
+
+    def done(self) :
+        """Displays the 'done' message."""
+        after = time.time()
+        if self.size :
+            try :
+                speed = self.size / ((after - self.before) + 0.00000000001) # adds an epsilon to avoid an user's problem I can't reproduce...
+            except ZeroDivisionError :
+                speed = 1 # Fake value in case of division by zero, shouldn't happen anyway with the epsilon above...
+            self.display("\r100.00%%\r        \r%s. %s : %.2f %s.\n" \
+                     % (_("Done"), _("Average speed"), speed, _("entries per second")))
+        else :
+            self.display("\r100.00%%\r        \r%s.\n" % _("Done"))
+
Index: /pykota/trunk/pykota/tool.py
===================================================================
--- /pykota/trunk/pykota/tool.py (revision 3432)
+++ /pykota/trunk/pykota/tool.py (revision 3434)
@@ -42,51 +42,4 @@
 from pykota import config, storage, logger
 from pykota.version import __version__, __author__, __years__, __gplblurb__
-
-class Percent :
-    """A class to display progress."""
-    def __init__(self, app, size=None) :
-        """Initializes the engine."""
-        self.isatty = sys.stdout.isatty()
-        self.app = app
-        self.size = None
-        if size :
-            self.setSize(size)
-        self.previous = None
-        self.before = time.time()
-
-    def setSize(self, size) :
-        """Sets the total size."""
-        self.number = 0
-        self.size = size
-        if size :
-            self.factor = 100.0 / float(size)
-
-    def display(self, msg) :
-        """Displays the value."""
-        if self.isatty :
-            self.app.display(msg)
-            sys.stdout.flush()
-
-    def oneMore(self) :
-        """Increments internal counter."""
-        if self.size :
-            self.number += 1
-            percent = "%.02f" % (float(self.number) * self.factor)
-            if percent != self.previous : # optimize for large number of items
-                self.display("\r%s%%" % percent)
-                self.previous = percent
-
-    def done(self) :
-        """Displays the 'done' message."""
-        after = time.time()
-        if self.size :
-            try :
-                speed = self.size / ((after - self.before) + 0.00000000001) # adds an epsilon to avoid an user's problem I can't reproduce...
-            except ZeroDivisionError :
-                speed = 1 # Fake value in case of division by zero, shouldn't happen anyway with the epsilon above...
-            self.display("\r100.00%%\r        \r%s. %s : %.2f %s.\n" \
-                     % (_("Done"), _("Average speed"), speed, _("entries per second")))
-        else :
-            self.display("\r100.00%%\r        \r%s.\n" % _("Done"))
 
 class Tool :
@@ -342,6 +295,6 @@
         for c in list(invalidchars) :
             if c in name :
-                return 0
-        return 1
+                return False
+        return True
 
     def _checkUserPQuota(self, userpquota) :
@@ -466,5 +419,5 @@
 
         # indicates that a warning needs to be sent
-        warned = 0
+        warned = False
 
         # first we check any group the user is a member of
@@ -480,5 +433,5 @@
                             return action
                         elif action == "WARN" :
-                            warned = 1
+                            warned = True
 
         # Then we check the user's account balance
@@ -515,5 +468,5 @@
         else :
             # Then check the user quota on current printer and all its parents.
-            policyallowed = 0
+            policyallowed = False
             for upquota in [ userpquota ] + userpquota.ParentPrintersUserPQuota :
                 action = self._checkUserPQuota(upquota)
@@ -521,7 +474,7 @@
                     return action
                 elif action == "WARN" :
-                    warned = 1
+                    warned = True
                 elif action == "POLICY_ALLOW" :
-                    policyallowed = 1
+                    policyallowed = True
             if warned :
                 return "WARN"
Index: /pykota/trunk/bin/edpykota
===================================================================
--- /pykota/trunk/bin/edpykota (revision 3432)
+++ /pykota/trunk/bin/edpykota (revision 3434)
@@ -30,6 +30,7 @@
 from pykota.commandline import PyKotaOptionParser
 from pykota.errors import PyKotaCommandLineError
-from pykota.tool import Percent, PyKotaTool
+from pykota.tool import PyKotaTool
 from pykota.storage import StorageUserPQuota, StorageGroupPQuota
+from pykota.progressbar import Percent
 
 class EdPyKota(PyKotaTool) :
Index: /pykota/trunk/bin/pkinvoice
===================================================================
--- /pykota/trunk/bin/pkinvoice (revision 3429)
+++ /pykota/trunk/bin/pkinvoice (revision 3434)
@@ -54,5 +54,6 @@
 from pykota.pdfutils import getPageSize
 from pykota.errors import PyKotaToolError, PyKotaCommandLineError
-from pykota.tool import Percent, PyKotaTool
+from pykota.tool import PyKotaTool
+from pykota.progressbar import Percent
 
 class PKInvoice(PyKotaTool) :
Index: /pykota/trunk/bin/pkbcodes
===================================================================
--- /pykota/trunk/bin/pkbcodes (revision 3417)
+++ /pykota/trunk/bin/pkbcodes (revision 3434)
@@ -32,6 +32,7 @@
 from pykota.commandline import PyKotaOptionParser
 from pykota.errors import PyKotaCommandLineError
-from pykota.tool import Percent, PyKotaTool
+from pykota.tool import PyKotaTool
 from pykota.storage import StorageBillingCode
+from pykota.progressbar import Percent
 
 class PKBcodes(PyKotaTool) :
Index: /pykota/trunk/bin/pkusers
===================================================================
--- /pykota/trunk/bin/pkusers (revision 3432)
+++ /pykota/trunk/bin/pkusers (revision 3434)
@@ -33,6 +33,7 @@
 from pykota.commandline import PyKotaOptionParser
 from pykota.errors import PyKotaCommandLineError
-from pykota.tool import Percent, PyKotaTool
+from pykota.tool import PyKotaTool
 from pykota.storage import StorageUser, StorageGroup
+from pykota.progressbar import Percent
 
 class PKUsers(PyKotaTool) :
Index: /pykota/trunk/bin/pkprinters
===================================================================
--- /pykota/trunk/bin/pkprinters (revision 3427)
+++ /pykota/trunk/bin/pkprinters (revision 3434)
@@ -32,6 +32,7 @@
 from pykota.commandline import PyKotaOptionParser
 from pykota.errors import PyKotaCommandLineError
-from pykota.tool import Percent, PyKotaTool
+from pykota.tool import PyKotaTool
 from pykota.storage import StoragePrinter
+from pykota.progressbar import Percent
 
 from pkipplib import pkipplib
Index: /pykota/trunk/bin/pkrefund
===================================================================
--- /pykota/trunk/bin/pkrefund (revision 3429)
+++ /pykota/trunk/bin/pkrefund (revision 3434)
@@ -53,5 +53,6 @@
 from pykota.pdfutils import getPageSize
 from pykota.errors import PyKotaToolError, PyKotaCommandLineError
-from pykota.tool import Percent, PyKotaTool
+from pykota.tool import PyKotaTool
+from pykota.progressbar import Percent
 
 class PKRefund(PyKotaTool) :
