Changeset 3029

Show
Ignore:
Timestamp:
10/07/06 11:41:13 (17 years ago)
Author:
jerome
Message:

Make the configuration file parser recognize the 'bw', 'cmyk', 'cmy', and 'rgb'
preaccounter and accounter directives.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/pykota/config.py

    r3025 r3029  
    192192    def getPreAccounterBackend(self, printername) :     
    193193        """Returns the preaccounter backend to use for a given printer.""" 
    194         validaccounters = [ "software" ]      
     194        validaccounters = [ "software", "bw", "cmyk", "cmy", "rgb" ]      
    195195        try : 
    196196            fullaccounter = self.getPrinterOption(printername, "preaccounter").strip() 
     
    199199        else :     
    200200            flower = fullaccounter.lower() 
    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)) 
    211211         
    212212    def getAccounterBackend(self, printername) :     
    213213        """Returns the accounter backend to use for a given printer.""" 
    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) 
    228232            raise PyKotaConfigError, _("Option accounter in section %s only supports values in %s") % (printername, str(validaccounters)) 
    229233