Changeset 2684

Show
Ignore:
Timestamp:
02/12/06 12:36:55 (18 years ago)
Author:
jerome
Message:

Reorganize code to optimize inner loop.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/bin/pkbcodes

    r2677 r2684  
    127127                    raise PyKotaCommandLineError, _("There's no billingcode matching %s") % " ".join(names) 
    128128                         
    129             if not options["list"] : 
     129            if options["list"] : 
     130                for billingcode in billingcodes : 
     131                    print "%s [%s] %s %s %s %.2f %s" % \ 
     132                          (billingcode.BillingCode, billingcode.Description, \ 
     133                           billingcode.PageCounter, \ 
     134                           _("pages"), \ 
     135                           _("and"), \ 
     136                           billingcode.Balance, \ 
     137                           _("credits")) 
     138            else :                
    130139                self.display("%s...\n" % _("Modification")) 
    131                  
    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 :     
     140                if options["description"] or options["reset"] : # optimize when nothing to do 
     141                    nbtotal = len(billingcodes)             
     142                    for i in range(nbtotal) :         
     143                        billingcode = billingcodes[i] 
    146144                        if options["reset"] : 
    147145                            billingcode.reset()