Index: pykota/trunk/bin/edpykota
===================================================================
--- pykota/trunk/bin/edpykota (revision 2731)
+++ pykota/trunk/bin/edpykota (revision 2735)
@@ -166,8 +166,9 @@
             self.display("%s...\n" % _("Deletion"))
             nbtotal = len(pqentries)
-            for i in range(nbtotal) :
-                (pqkey, pqentry) = pqentries.popitem()
+            i = 0
+            for (pqkey, pqentry) in pqentries.items() :
                 if pqentry.Exists :
                     pqentry.delete()
+                i += 1    
                 percent = 100.0 * float(i) / float(nbtotal)
                 self.display("\r%.02f%%" % percent)
@@ -197,7 +198,7 @@
                             else :
                                 pqentries[pqkey] = newpqentry
+                        i += 1
                         percent = 100.0 * float(i) / float(nbtotal)
                         self.display("\r%.02f%%" % percent)
-                        i += 1
                 self.display("\r100.00%%\r        \r%s\n" % _("Done."))
                 
@@ -220,6 +221,4 @@
             else :
                 self.display("%s...\n" % _("Modification"))
-                raise PyKotaCommandLineError, "Not implemented yet."
-                softlimit = hardlimit = None
                 
                 used = options["used"]
@@ -238,5 +237,7 @@
                         raise PyKotaCommandLineError, _("Invalid increase value %s.") % increase
                 
-                if not options["noquota"] :
+                softlimit = hardlimit = None
+                noquota = options["noquota"]
+                if not noquota :
                     if options["softlimit"] :
                         try :
@@ -257,80 +258,48 @@
                         self.printInfo(_("Hard limit %i is less than soft limit %i, values will be exchanged.") % (hardlimit, softlimit))
                         (softlimit, hardlimit) = (hardlimit, softlimit)
+                    if hardlimit is None :    
+                        hardlimit = softlimit
+                        if hardlimit is not None :
+                            self.printInfo(_("Undefined hard limit set to soft limit (%s) on printer %s.") % (str(hardlimit), printer.Name))
+                    if softlimit is None :    
+                        softlimit = hardlimit
+                        if softlimit is not None :
+                            self.printInfo(_("Undefined soft limit set to hard limit (%s) on printer %s.") % (str(softlimit), printer.Name))
                     
-                sys.stdout.write(_("Managing print quotas... (this may take a lot of time)"))
-                sys.stdout.flush()
-                missingusers = {}
-                missinggroups = {}    
-                changed = {} # tracks changes made at the user/group level
-                for printer in printers :
-                    if not options["noquota"] :    
-                        if hardlimit is None :    
-                            hardlimit = softlimit
-                            if hardlimit is not None :
-                                self.printInfo(_("Undefined hard limit set to soft limit (%s) on printer %s.") % (str(hardlimit), printer.Name))
-                        if softlimit is None :    
-                            softlimit = hardlimit
-                            if softlimit is not None :
-                                self.printInfo(_("Undefined soft limit set to hard limit (%s) on printer %s.") % (str(softlimit), printer.Name))
+                nbtotal = len(pqentries)    
+                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 :
+                           if (pqentry.SoftLimit is None) \
+                               or (pqentry.HardLimit is None) :
+                               self.printInfo(_("You can't increase limits by %s when no limit is set.") % increase, "error")
+                           else :
+                               newsoft = pqentry.SoftLimit + increase         
+                               newhard = pqentry.HardLimit + 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)
                                 
-                    if options["add"] :    
-                        allentries = []    
-                        for name in names :
-                            email = ""
-                            if not options["groups"] :
-                                splitname = name.split('/', 1)     # username/email
-                                if len(splitname) == 1 :
-                                    splitname.append("")
-                                (name, email) = splitname
-                                if email and (email.count('@') != 1) :
-                                    self.printInfo(_("Invalid email address %s") % email)
-                                    email = ""
-                            entry = getattr(self.storage, "get%s" % suffix)(name)
-                            if email and not options["groups"] :
-                                entry.Email = email
-                            entrypquota = getattr(self.storage, "get%sPQuota" % suffix)(entry, printer)
-                            allentries.append((entry, entrypquota))
-                    else :   
-                        allentries = getattr(self.storage, "getPrinter%ssAndQuotas" % suffix)(printer, names)
-                        
-                    for (entry, entrypquota) in allentries :
-                        if not changed.has_key(entry.Name) :
-                            changed[entry.Name] = {}
-                            if not options["groups"] :
-                                changed[entry.Name]["ingroups"] = []
-                                
-                        if entry.Exists and (not entrypquota.Exists) :
-                            # not found
-                            if options["add"] :
-                                entrypquota = getattr(self.storage, "add%sPQuota" % suffix)(entry, printer)
-                                
-                        if not entrypquota.Exists :     
-                            self.printInfo(_("Quota not found for object %s on printer %s.") % (entry.Name, printer.Name))
-                        else :    
-                            if options["noquota"] \
-                               or ((softlimit is not None) and (hardlimit is not None)) :
-                                entrypquota.setLimits(softlimit, hardlimit)
-                                
-                            if increase :
-                               if (entrypquota.SoftLimit is None) \
-                                   or (entrypquota.HardLimit is None) :
-                                   self.printInfo(_("You can't increase limits by %s when no limit is set.") % increase, "error")
-                               else :
-                                   newsoft = entrypquota.SoftLimit + increase         
-                                   newhard = entrypquota.HardLimit + increase         
-                                   if (newsoft >= 0) and (newhard >= 0) :
-                                       entrypquota.setLimits(newsoft, newhard)
-                                   else :    
-                                       self.printInfo(_("You can't set negative limits."), "error")
-                            
-                            if options["reset"] :
-                                entrypquota.reset()
-                                
-                            if options["hardreset"] :    
-                                entrypquota.hardreset()
-                                
-                            if not options["groups"] :
-                                if used :
-                                    entrypquota.setUsage(used)
+                        pqentry.save()        
+                    i += 1            
+                    percent = 100.0 * float(i) / float(nbtotal)
+                    self.display("\r%.02f%%" % percent)
                                 
         if not options["list"] :                
