137 | | def getAllUsersNames(self) : |
| 137 | def filterNames(self, records, attribute, patterns=None) : |
| 138 | """Returns a list of 'attribute' from a list of records. |
| 139 | |
| 140 | Logs any missing attribute. |
| 141 | """ |
| 142 | result = [] |
| 143 | for record in records : |
| 144 | attrval = record.get(attribute, [None]) |
| 145 | if attrval is None : |
| 146 | self.tool.printInfo("Object %s has no %s attribute !" % (repr(record), attribute), "error") |
| 147 | else : |
| 148 | if patterns : |
| 149 | if (not isinstance(patterns, type([]))) and (not isinstance(patterns, type(()))) : |
| 150 | patterns = [ patterns ] |
| 151 | patterns = [self.userCharsetToDatabase(p) for p in patterns] |
| 152 | if self.tool.matchString(attrval, patterns) : |
| 153 | result.append(attrval) |
| 154 | else : |
| 155 | result.append(attrval) |
| 156 | return result |
| 157 | |
| 158 | def getAllBillingCodes(self, billingcode=None) : |
| 159 | """Extracts all billing codes or only the billing codes matching the optional parameter.""" |
| 160 | result = self.doSearch("SELECT billingcode FROM billingcodes") |
| 161 | if result : |
| 162 | return self.filterNames(result, "billingcode", billingcode) |
| 163 | else : |
| 164 | return [] |
| 165 | |
| 166 | def getAllPrintersNames(self, printername=None) : |
| 167 | """Extracts all printer names or only the printers' names matching the optional parameter.""" |
| 168 | result = self.doSearch("SELECT printername FROM printers") |
| 169 | if result : |
| 170 | return self.filterNames(result, "printername", printername) |
| 171 | else : |
| 172 | return [] |
| 173 | |
| 174 | def getAllUsersNames(self, username=None) : |