201 | | if flower.startswith("software") : |
202 | | try : |
203 | | (accounter, args) = [x.strip() for x in fullaccounter.split('(', 1)] |
204 | | except ValueError : |
205 | | raise PyKotaConfigError, _("Invalid preaccounter %s for printer %s") % (fullaccounter, printername) |
206 | | if args.endswith(')') : |
207 | | args = args[:-1].strip() |
208 | | return ("software", args) |
209 | | else : |
210 | | raise PyKotaConfigError, _("Option preaccounter in section %s only supports values in %s") % (printername, str(validaccounters)) |
| 201 | for vac in validaccounters : |
| 202 | if flower.startswith(vac) : |
| 203 | try : |
| 204 | (accounter, args) = [x.strip() for x in fullaccounter.split('(', 1)] |
| 205 | except ValueError : |
| 206 | raise PyKotaConfigError, _("Invalid preaccounter %s for printer %s") % (fullaccounter, printername) |
| 207 | if args.endswith(')') : |
| 208 | args = args[:-1].strip() |
| 209 | return (vac, args) |
| 210 | raise PyKotaConfigError, _("Option preaccounter in section %s only supports values in %s") % (printername, str(validaccounters)) |
214 | | validaccounters = [ "hardware", "software" ] |
215 | | fullaccounter = self.getPrinterOption(printername, "accounter").strip() |
216 | | flower = fullaccounter.lower() |
217 | | if flower.startswith("software") or flower.startswith("hardware") : |
218 | | try : |
219 | | (accounter, args) = [x.strip() for x in fullaccounter.split('(', 1)] |
220 | | except ValueError : |
221 | | raise PyKotaConfigError, _("Invalid accounter %s for printer %s") % (fullaccounter, printername) |
222 | | if args.endswith(')') : |
223 | | args = args[:-1].strip() |
224 | | if (accounter == "hardware") and not args : |
225 | | raise PyKotaConfigError, _("Invalid accounter %s for printer %s") % (fullaccounter, printername) |
226 | | return (accounter.lower(), args) |
227 | | else : |
| 214 | validaccounters = [ "hardware", "software", "bw", "cmyk", "cmy", "rgb" ] |
| 215 | try : |
| 216 | fullaccounter = self.getPrinterOption(printername, "accounter").strip() |
| 217 | except PyKotaConfigError : |
| 218 | return ("software", "") |
| 219 | else : |
| 220 | flower = fullaccounter.lower() |
| 221 | for vac in validaccounters : |
| 222 | if flower.startswith(vac) : |
| 223 | try : |
| 224 | (accounter, args) = [x.strip() for x in fullaccounter.split('(', 1)] |
| 225 | except ValueError : |
| 226 | raise PyKotaConfigError, _("Invalid accounter %s for printer %s") % (fullaccounter, printername) |
| 227 | if args.endswith(')') : |
| 228 | args = args[:-1].strip() |
| 229 | if (accounter == "hardware") and not args : |
| 230 | raise PyKotaConfigError, _("Invalid accounter %s for printer %s") % (fullaccounter, printername) |
| 231 | return (vac, args) |