Index: /pykota/trunk/pykota/version.py
===================================================================
--- /pykota/trunk/pykota/version.py (revision 2746)
+++ /pykota/trunk/pykota/version.py (revision 2755)
@@ -22,5 +22,5 @@
 #
 
-__version__ = "1.24alpha13_unofficial"
+__version__ = "1.24alpha14_unofficial"
 
 __doc__ = "PyKota : a complete Printing Quota Solution for CUPS."
Index: /pykota/trunk/bin/edpykota
===================================================================
--- /pykota/trunk/bin/edpykota (revision 2749)
+++ /pykota/trunk/bin/edpykota (revision 2755)
@@ -1,3 +1,3 @@
-#! /usr/bin/env python
+#!/usr/bin/python
 # -*- coding: ISO-8859-15 -*-
 
@@ -153,4 +153,23 @@
 class EdPyKota(PyKotaTool) :        
     """A class for edpykota."""
+    def modifyPQEntry(self, pqkey, pqentry, noquota, softlimit, hardlimit, increase, reset, hardreset, suffix, used) :
+        """Modifies a print quota entry."""
+        if noquota or ((softlimit is not None) and (hardlimit is not None)) :
+            pqentry.setLimits(softlimit, hardlimit)
+        if increase :
+            newsoft = (pqentry.SoftLimit or 0) + increase         
+            newhard = (pqentry.HardLimit or 0) + increase         
+            if (newsoft >= 0) and (newhard >= 0) :
+                pqentry.setLimits(newsoft, newhard)
+            else :    
+                self.printInfo(_("You can't set negative limits for %s") % pqkey, "error")
+        if reset :
+            pqentry.reset()
+        if hardreset :    
+            pqentry.hardreset()
+        if suffix == "User" :
+            if used :
+                pqentry.setUsage(used)
+    
     def main(self, names, options) :
         """Edit user or group quotas."""
@@ -173,5 +192,21 @@
             self.display("\n")
             self.display("\r100.00%%\r        \r%s\n" % _("Done."))
+        elif options["list"] :
+            for printer in printers :
+                for entry in entries :
+                    pqentry = getattr(self.storage, "get%sPQuota" % suffix)(entry, printer)
+                    if pqentry.Exists :
+                        print "%s@%s" % (entry.Name, printer.Name)
+                        print "    %s" % (_("Page counter : %s") % pqentry.PageCounter)
+                        print "    %s" % (_("Lifetime page counter : %s") % pqentry.LifePageCounter)
+                        print "    %s" % (_("Soft limit : %s") % pqentry.SoftLimit)
+                        print "    %s" % (_("Hard limit : %s") % pqentry.HardLimit)
+                        print "    %s" % (_("Date limit : %s") % pqentry.DateLimit)
+                        print "    %s (Not supported yet)" % (_("Maximum job size : %s") % ((pqentry.MaxJobSize and (_("%s pages") % pqentry.MaxJobSize)) or _("Unlimited")))
+                        if hasattr(pqentry, "WarnCount") :
+                            print "    %s" % (_("Warning banners printed : %s") % pqentry.WarnCount)
+                        print
         else :
+            self.display("\n")    
             skipexisting = options["skipexisting"]
             used = options["used"]
@@ -190,6 +225,8 @@
                     raise PyKotaCommandLineError, _("Invalid increase value %s.") % increase
             
+            noquota = options["noquota"]
+            reset = options["reset"]        
+            hardreset = options["hardreset"]
             softlimit = hardlimit = None
-            noquota = options["noquota"]
             if not noquota :
                 if options["softlimit"] :
@@ -220,7 +257,6 @@
                         self.printInfo(_("Undefined soft limit set to hard limit (%s).") % str(softlimit))
                         
-            pqentries = []            
             if options["add"] :
-                self.display("\n%s...\n" % _("Creation"))
+                self.display("%s...\n" % _("Creation"))
                 dicnames = {}
                 for m in entries :
@@ -239,92 +275,41 @@
                         pqkey = "%s@%s" % (ename, pname)
                         pqentry = factory(self.storage, entry, printer)
-                        if noquota or ((softlimit is not None) and (hardlimit is not None)) :
-                            pqentry.setLimits(softlimit, hardlimit)
-                            
-                        if increase :
-                            newsoft = (pqentry.SoftLimit or 0) + increase         
-                            newhard = (pqentry.HardLimit or 0) + increase         
-                            if (newsoft >= 0) and (newhard >= 0) :
-                                pqentry.setLimits(newsoft, newhard)
-                            else :    
-                                self.printInfo(_("You can't set negative limits."), "error")
-                        
-                        if options["reset"] :
-                            pqentry.reset()
-                            
-                        if options["hardreset"] :    
-                            pqentry.hardreset()
-                            
-                        if not options["groups"] :
-                            if used :
-                                pqentry.setUsage(used)
-                        
+                        self.modifyPQEntry(pqkey, pqentry, noquota, \
+                                                    softlimit, hardlimit, \
+                                                    increase, reset, \
+                                                    hardreset, suffix, used)
                         oldpqentry = getattr(self.storage, "add%sPQuota" % suffix)(pqentry)
                         if oldpqentry is not None :    
                             if skipexisting :
-                                self.printInfo(_("%s print quota entry %s@%s already exists, skipping.") % (suffix, ename, pname))
+                                self.logdebug("%s print quota entry %s@%s already exists, skipping." % (suffix, ename, pname))
                             else :    
-                                self.printInfo(_("%s print quota entry %s@%s already exists, will be modified.") % (suffix, ename, pname))
-                                pqentries.append(oldpqentry)
+                                self.logdebug("%s print quota entry %s@%s already exists, will be modified." % (suffix, ename, pname))
+                                self.modifyPQEntry(pqkey, oldpqentry, noquota, \
+                                                    softlimit, hardlimit, \
+                                                    increase, reset, \
+                                                    hardreset, suffix, used)
+                                oldpqentry.save()                    
                         i += 1
                         percent = 100.0 * float(i) / float(nbtotal)
                         self.display("\r%.02f%%" % percent)
-                self.display("\r100.00%%\r        \r%s" % _("Done."))
-            else :    
-                for printer in printers :
-                    for entry in entries :
-                        pqentries.append(getattr(self.storage, "get%sPQuota" % suffix)(entry, printer))
-                if not pqentries :        
-                    raise PyKotaCommandLineError, _("There's no %s print quota entry matching %s") % (suffix.lower(), " ".join(names))
-                    
-            if options["list"] :
-                for pqentry in pqentries :
-                    if pqentry.Exists :
-                        print "%s@%s" % (getattr(pqentry, suffix).Name, pqentry.Printer.Name)
-                        print "    %s" % (_("Page counter : %s") % pqentry.PageCounter)
-                        print "    %s" % (_("Lifetime page counter : %s") % pqentry.LifePageCounter)
-                        print "    %s" % (_("Soft limit : %s") % pqentry.SoftLimit)
-                        print "    %s" % (_("Hard limit : %s") % pqentry.HardLimit)
-                        print "    %s" % (_("Date limit : %s") % pqentry.DateLimit)
-                        print "    %s (Not supported yet)" % (_("Maximum job size : %s") % ((pqentry.MaxJobSize and (_("%s pages") % pqentry.MaxJobSize)) or _("Unlimited")))
-                        if hasattr(pqentry, "WarnCount") :
-                            print "    %s" % (_("Warning banners printed : %s") % pqentry.WarnCount)
-                        print
-            else :
-                self.display("\n")
-                nbtotal = len(pqentries)    
+            else :        
+                nbtotal = len(entries) * len(printers)
                 if nbtotal :
                     self.display("%s...\n" % _("Modification"))
                     i = 0
-                    for pqentry in pqentries :
-                        ename = getattr(pqentry, suffix).Name
-                        pname = pqentry.Printer.Name
-                        if pqentry.Exists :     
-                            if noquota or ((softlimit is not None) and (hardlimit is not None)) :
-                                pqentry.setLimits(softlimit, hardlimit)
-                                
-                            if increase :
-                                newsoft = (pqentry.SoftLimit or 0) + increase         
-                                newhard = (pqentry.HardLimit or 0) + increase         
-                                if (newsoft >= 0) and (newhard >= 0) :
-                                    pqentry.setLimits(newsoft, newhard)
-                                else :    
-                                    self.printInfo(_("You can't set negative limits for %s@%s") % (ename, pname), "error")
-                            
-                            if options["reset"] :
-                                pqentry.reset()
-                                
-                            if options["hardreset"] :    
-                                pqentry.hardreset()
-                                
-                            if not options["groups"] :
-                                if used :
-                                    pqentry.setUsage(used)
-                                    
-                            pqentry.save()        
-                        i += 1            
-                        percent = 100.0 * float(i) / float(nbtotal)
-                        self.display("\r%.02f%%" % percent)
-                    self.display("\r100.00%%\r        \r%s\n" % _("Done."))
+                    for printer in printers :
+                        for entry in entries :
+                            pqkey = "%s@%s" % (entry.Name, printer.Name)
+                            pqentry = getattr(self.storage, "get%sPQuota" % suffix)(entry, printer)
+                            if pqentry.Exists :     
+                                self.modifyPQEntry(pqkey, pqentry, noquota, \
+                                                    softlimit, hardlimit, \
+                                                    increase, reset, \
+                                                    hardreset, suffix, used)
+                                pqentry.save()        
+                            i += 1            
+                            percent = 100.0 * float(i) / float(nbtotal)
+                            self.display("\r%.02f%%" % percent)
+            self.display("\r100.00%%\r        \r%s\n" % _("Done."))
                      
 if __name__ == "__main__" : 
Index: /pykota/trunk/NEWS
===================================================================
--- /pykota/trunk/NEWS (revision 2746)
+++ /pykota/trunk/NEWS (revision 2755)
@@ -22,4 +22,9 @@
 PyKota NEWS :
        
+    - 1.24alpha14 :
+    
+        - Finished optimizations in edpykota and fixed some minor
+          problems with LDAP.
+          
     - 1.24alpha13 :
     
