Show
Ignore:
Timestamp:
04/16/04 18:47:58 (20 years ago)
Author:
jalet
Message:

pkprinters now accept the --list command line option

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/bin/pkprinters

    r1332 r1437  
    2424# 
    2525# $Log$ 
     26# Revision 1.4  2004/04/16 16:47:57  jalet 
     27# pkprinters now accept the --list command line option 
     28# 
    2629# Revision 1.3  2004/02/04 13:24:41  jalet 
    2730# pkprinters can now remove printers from printers groups. 
     
    8083                       printer groups. 
    8184                        
     85  -l | --list          List informations about the printer(s) and the 
     86                       printers groups it is a member of. 
     87                        
    8288  -r | --remove        In combination with the --groups option above,                        
    8389                       remove printers from the specified printers groups. 
     
    130136    def main(self, names, options) : 
    131137        """Manage printers.""" 
     138        if options["list"] and not names : 
     139            names = ["*"] 
     140             
    132141        if options["groups"] :         
    133142            printersgroups = self.storage.getMatchingPrinters(options["groups"]) 
     
    167176            if options["delete"] : 
    168177                printer.delete() 
     178            elif options["list"] :     
     179                parents = ", ".join([p.Name for p in self.storage.getParentPrinters(printer)]) 
     180                if parents :  
     181                    parents = "%s %s" % (_("in"), parents) 
     182                print "%s (%s + %s) %s" % \ 
     183                      (printer.Name, printer.PricePerJob, \ 
     184                       printer.PricePerPage, parents) 
    169185            else :     
    170186                if options["charge"] : 
     
    180196    retcode = 0 
    181197    try : 
    182         short_options = "hvac:dg:r" 
    183         long_options = ["help", "version", "add", "charge=", "delete", "groups=", "remove"] 
     198        short_options = "hvac:dg:lr" 
     199        long_options = ["help", "version", "add", "charge=", "delete", "groups=", "list", "remove"] 
    184200         
    185201        # Initializes the command line tool 
     
    196212        options["delete"] = options["d"] or options["delete"]  
    197213        options["groups"] = options["g"] or options["groups"] 
     214        options["list"] = options["l"] or options["list"] 
    198215        options["remove"] = options["r"] or options["remove"] 
    199216         
     
    202219        elif options["version"] : 
    203220            manager.display_version_and_quit() 
    204         elif options["delete"] and (options["add"] or options["groups"] or options["charge"] or options["remove"]) :     
     221        elif (options["delete"] and (options["add"] or options["groups"] or options["charge"] or options["remove"])) \ 
     222           or (options["list"] and (options["add"] or options["delete"] or options["groups"] or options["charge"] or options["remove"])) : 
    205223            raise PyKotaToolError, _("incompatible options, see help.") 
    206224        elif options["remove"] and not options["groups"] :     
    207225            raise PyKotaToolError, _("You have to pass printer groups names on the command line") 
    208         elif not args :     
     226        elif (not args) and (not options["list"]) :     
    209227            raise PyKotaToolError, _("You have to pass printer names on the command line") 
    210228        else :