Changeset 2677

Show
Ignore:
Timestamp:
02/12/06 00:15:49 (18 years ago)
Author:
jerome
Message:

Ensures that pkbcodes doesn't enter the modification loop if there's nothing to modify.

Location:
pykota/trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/bin/pkbcodes

    r2676 r2677  
    130130                self.display("%s...\n" % _("Modification")) 
    131131                 
    132             nbtotal = len(billingcodes)             
    133             for i in range(nbtotal) :         
    134                 billingcode = billingcodes[i] 
    135                 if options["list"] :     
    136                     print "%s [%s] %s %s %s %.2f %s" % \ 
    137                           (billingcode.BillingCode, billingcode.Description, \ 
    138                            billingcode.PageCounter, \ 
    139                            _("pages"), \ 
    140                            _("and"), \ 
    141                            billingcode.Balance, \ 
    142                            _("credits")) 
    143                 else :     
    144                     if options["reset"] : 
    145                         billingcode.reset()     
    146                     if options["description"] is not None : 
    147                         billingcode.setDescription(options["description"].strip()) 
    148                     billingcode.save()     
    149                     percent = 100.0 * float(i) / float(nbtotal) 
    150                     self.display("\r%.02f%%" % percent) 
     132            if (not options["add"]) \ 
     133                or options["description"] or options["reset"] : # optimize when nothing to do 
     134                nbtotal = len(billingcodes)             
     135                for i in range(nbtotal) :         
     136                    billingcode = billingcodes[i] 
     137                    if options["list"] :     
     138                        print "%s [%s] %s %s %s %.2f %s" % \ 
     139                              (billingcode.BillingCode, billingcode.Description, \ 
     140                               billingcode.PageCounter, \ 
     141                               _("pages"), \ 
     142                               _("and"), \ 
     143                               billingcode.Balance, \ 
     144                               _("credits")) 
     145                    else :     
     146                        if options["reset"] : 
     147                            billingcode.reset()     
     148                        if options["description"] is not None : 
     149                            billingcode.setDescription(options["description"].strip()) 
     150                        billingcode.save()     
     151                        percent = 100.0 * float(i) / float(nbtotal) 
     152                        self.display("\r%.02f%%" % percent) 
    151153                         
    152154        if not options["list"] :                 
  • pykota/trunk/NEWS

    r2675 r2677  
    2424    - 1.24alpha11 : 
    2525     
     26        - Huge speed improvements when modifying billing codes. 
     27         
    2628        - Both pkbcodes and pkprinters now display the percent done 
    2729          for all actions.