38 | | from pykota.storage import PyKotaStorageError, BaseStorage, StorageObject, StorageUser, StorageGroup, StoragePrinter, StorageJob, StorageLastJob, StorageUserPQuota, StorageGroupPQuota |
| 38 | from pykota.storage import PyKotaStorageError, BaseStorage, StorageObject, \ |
| 39 | StorageUser, StorageGroup, StoragePrinter, \ |
| 40 | StorageJob, StorageLastJob, StorageUserPQuota, \ |
| 41 | StorageGroupPQuota, StorageBillingCode |
1405 | | # def getMatchingBillingCodes(self, billingcodepattern) : |
1406 | | # def writeBillingCodeDescription(self, code) : |
| 1408 | def getMatchingBillingCodes(self, billingcodepattern) : |
| 1409 | """Returns the list of all billing codes which match a certain pattern.""" |
| 1410 | codes = [] |
| 1411 | result = self.doSearch("(&(objectClass=pykotaBilling)%s)" % "".join(["(pykotaBillingCode=%s)" % self.userCharsetToDatabase(bcode) for bcode in billingcodepattern.split(",")]), \ |
| 1412 | ["pykotaBillingCode", "description", "pykotaPageCounter", "pykotaBalance"], \ |
| 1413 | base=self.info["billingcodebase"]) |
| 1414 | if result : |
| 1415 | for (codeid, fields) in result : |
| 1416 | codename = self.databaseToUserCharset(fields.get("pykotaBillingCode", [""])[0]) |
| 1417 | code = StorageBillingCode(self, codename) |
| 1418 | code.ident = codeid |
| 1419 | code.BillingCode = codename |
| 1420 | code.PageCounter = int(fields.get("pykotaPageCounter", [0])[0]) |
| 1421 | code.Balance = float(fields.get("pykotaBalance", [0.0])[0]) |
| 1422 | code.Description = self.databaseToUserCharset(fields.get("description", [""])[0]) |
| 1423 | code.Exists = 1 |
| 1424 | codes.append(code) |
| 1425 | self.cacheEntry("BILLINGCODES", code.BillingCode, code) |
| 1426 | return codes |
| 1427 | |