Changeset 2661
- Timestamp:
- 02/10/06 21:52:01 (19 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/bin/pkinvoice
r2660 r2661 48 48 -g | --groups Generate invoices for users groups instead of users. 49 49 50 -l | --logo img Use the image as the banner's logo. The logo will 51 be drawn at the center top of the page. The default 52 logo is /usr/share/pykota/logos/pykota.jpeg 53 54 -p | --pagesize sz Sets sz as the page size. Most well known 55 page sizes are recognized, like 'A4' or 'Letter' 56 to name a few. The default size is A4. 57 58 -n | --number N Sets the number of the first invoice. This number 59 will automatically be incremented for each invoice. 60 50 61 -r | --reference v Uses v as the initial reference value : an invoice 51 62 will be generated for any account balance's value … … 87 98 raise PyKotaCommandLineError, "%s : %s" % (pwd.getpwuid(os.geteuid())[0], _("You're not allowed to use this command.")) 88 99 89 self.display("%s...\n" % _("Processing")) 100 try : 101 vat = float(options["vat"]) 102 if not (0.0 <= vat < 100.0) : 103 raise ValueError 104 except : 105 raise PyKotaCommandLineError, _("Incorrect value '%s' for the --vat command line option") % options["vat"] 106 107 try : 108 reference = float(options["reference"]) 109 except : 110 raise PyKotaCommandLineError, _("Incorrect value '%s' for the --reference command line option") % options["reference"] 111 112 try : 113 number = float(options["number"]) 114 if number <= 0 : 115 raise ValueError 116 except : 117 raise PyKotaCommandLineError, _("Incorrect value '%s' for the --number command line option") % options["number"] 118 90 119 if not names : 91 120 names = [ "*" ] 121 122 outfname = options["output"] 123 if outfname != "-" : 124 self.display("%s...\n" % _("Processing")) 92 125 93 126 suffix = (options["groups"] and "Group") or "User" … … 98 131 # TODO 99 132 percent = 100.0 * float(i) / float(nbtotal) 100 self.display("\r%.02f%%" % percent) 101 self.display("\r100.00%%\r ") 102 self.display("\r%s\n" % _("Done.")) 133 if outfname != "-" : 134 self.display("\r%.02f%%" % percent) 135 if outfname != "-" : 136 self.display("\r100.00%%\r ") 137 self.display("\r%s\n" % _("Done.")) 103 138 104 139 if __name__ == "__main__" : … … 109 144 "unit" : _("Credits"), 110 145 "output" : "-", 146 "pagesize" : "a4", \ 147 "logo" : "/usr/share/pykota/logos/pykota.jpeg", 148 "number" : "1", 111 149 } 112 short_options = "vho:gr:u:V: "150 short_options = "vho:gr:u:V:p:l:" 113 151 long_options = ["help", "version", \ 114 152 "groups", "reference=", "unit=", "output=", \ 115 " vat=",]153 "pagesize=", "logo=", "vat=", "number="] 116 154 117 155 # Initializes the command line tool … … 131 169 options["unit"] = options["u"] or options["unit"] or defaults["unit"] 132 170 options["output"] = options["o"] or options["output"] or defaults["output"] 171 options["pagesize"] = options["p"] or options["pagesize"] or defaults["pagesize"] 172 options["number"] = options["n"] or options["number"] or defaults["number"] 173 options["logo"] = options["l"] or options["logo"] 174 if options["logo"] is None : # Allows --logo="" to disable the logo entirely 175 options["logo"] = defaults["logo"] 133 176 134 177 if options["help"] :