117 | | elif options["add"] : |
118 | | self.display("%s...\n" % _("Creation")) |
119 | | nbtotal = len(names) |
120 | | for i in range(nbtotal) : |
121 | | bname = names[i] |
122 | | billingcode = StorageBillingCode(self.storage, bname) |
123 | | self.modifyBillingCode(billingcode, reset, description) |
124 | | oldbillingcode = self.storage.addBillingCode(billingcode) |
125 | | if oldbillingcode is not None : |
126 | | if options["skipexisting"] : |
127 | | self.printInfo(_("Billing code [%s] already exists, skipping.") % bname) |
128 | | else : |
129 | | self.printInfo(_("Billing code [%s] already exists, will be modified.") % bname) |
130 | | self.modifyBillingCode(oldbillingcode, reset, description) |
131 | | oldbillingcode.save() |
132 | | percent = 100.0 * float(i) / float(nbtotal) |
133 | | self.display("\r%.02f%%" % percent) |
134 | | else : |
135 | | if options["list"] : |
136 | | for billingcode in billingcodes : |
137 | | if billingcode.Exists : |
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 : |
| 121 | else : |
| 122 | reset = options["reset"] |
| 123 | description = options["description"] |
| 124 | if description : |
| 125 | description = options["description"].strip() |
| 126 | skipexisting = options["skipexisting"] |
| 127 | if options["add"] : |
| 128 | self.display("%s...\n" % _("Creation")) |
| 129 | nbtotal = len(names) |
| 130 | for i in range(nbtotal) : |
| 131 | bname = names[i] |
| 132 | billingcode = StorageBillingCode(self.storage, bname) |
| 133 | self.modifyBillingCode(billingcode, reset, description) |
| 134 | oldbillingcode = self.storage.addBillingCode(billingcode) |
| 135 | if oldbillingcode is not None : |
| 136 | if skipexisting : |
| 137 | self.printInfo(_("Billing code [%s] already exists, skipping.") % bname) |
| 138 | else : |
| 139 | self.printInfo(_("Billing code [%s] already exists, will be modified.") % bname) |
| 140 | self.modifyBillingCode(oldbillingcode, reset, description) |
| 141 | oldbillingcode.save() |
| 142 | percent = 100.0 * float(i) / float(nbtotal) |
| 143 | self.display("\r%.02f%%" % percent) |
| 144 | else : |