53 | | __doc__ = N_("""pkbanner v%(__version__)s (c) %(__years__)s %(__author__)s |
54 | | |
55 | | Generates banners. |
56 | | |
57 | | command line usage : |
58 | | |
59 | | pkbanner [options] [more info] |
60 | | |
61 | | options : |
62 | | |
63 | | -v | --version Prints pkbanner's version number then exits. |
64 | | -h | --help Prints this message then exits. |
65 | | |
66 | | -l | --logo img Use the image as the banner's logo. The logo will |
67 | | be drawn at the center top of the page. The default |
68 | | logo is /usr/share/pykota/logos/pykota.jpeg |
69 | | |
70 | | -p | --pagesize sz Sets sz as the page size. Most well known |
71 | | page sizes are recognized, like 'A4' or 'Letter' |
72 | | to name a few. The default size is A4. |
73 | | |
74 | | -s | --savetoner s Sets the text luminosity factor to s%%. This can be |
75 | | used to save toner. The default value is 0, which |
76 | | means that no toner saving will be done. |
77 | | |
78 | | -u | --url u Uses u as an url to be written at the bottom of |
79 | | the banner page. The default url is : |
80 | | http://www.pykota.com/ |
81 | | |
82 | | examples : |
83 | | |
84 | | Using pkbanner directly from the command line is not recommended, |
85 | | excepted for testing purposes. You should use pkbanner in the |
86 | | 'startingbanner' or 'endingbanner' directives in pykota.conf |
87 | | |
88 | | startingbanner: /usr/bin/pkbanner --logo="" --savetoner=75 |
89 | | |
90 | | With such a setting in pykota.conf, all print jobs will be |
91 | | prefixed with an A4 banner with no logo, and text luminosity will |
92 | | be increased by 75%%. The PostScript output will be directly sent |
93 | | to your printer. |
94 | | |
95 | | You'll find more examples in the sample configuration file included |
96 | | in PyKota. |
97 | | """) |
98 | | |
| 252 | parser = parser.PyKotaOptionParser(description=_("Banner generator for PyKota")) |
| 253 | parser.add_option("-l", "--logo", |
| 254 | dest="logo", |
| 255 | default=u"/usr/share/pykota/logos/pykota.jpeg", |
| 256 | help=_("The image to use as the banner's logo. The logo will be drawn at the center top of the page. The default logo is %default")) |
| 257 | parser.add_option("-p", "--pagesize", |
| 258 | dest="pagesize", |
| 259 | default=u"A4", |
| 260 | help=_("Sets the size of the page. Most well known page sizes are recognized, like 'A4' or 'Letter' to name a few. The default page size is %default")) |
| 261 | parser.add_option("-s", "--savetoner", |
| 262 | dest="savetoner", |
| 263 | type="int", |
| 264 | default=0, |
| 265 | help=_("Sets the text luminosity to this percent. This can be used to save toner. The default value is %default, which means that no toner saving will be done.")) |
| 266 | parser.add_option("-u", "--url", |
| 267 | dest="url", |
| 268 | default=u"http://www.pykota.com", |
| 269 | help=_("Sets the url to write at the bottom of the banner page. The default url is %default")) |
| 270 | parser.add_example('--logo="" --savetoner=75', |
| 271 | _("This would generate an A4 banner with no logo, and text luminosity would be increased by 75%%.")) |
| 272 | (options, arguments) = parser.parse_args() |
| 273 | if options.version : |
| 274 | from pykota import version |
| 275 | sys.stdout.write("%s\n" % version.__version__) |
| 276 | sys.exit(0) |
| 277 | |
309 | | |
310 | | # parse and checks the command line |
311 | | (options, args) = banner.parseCommandline(sys.argv[1:], short_options, long_options, allownothing=1) |
312 | | |
313 | | # sets long options |
314 | | options["help"] = options["h"] or options["help"] |
315 | | options["version"] = options["v"] or options["version"] |
316 | | options["savetoner"] = options["s"] or options["savetoner"] or defaults["savetoner"] |
317 | | options["pagesize"] = options["p"] or options["pagesize"] or defaults["pagesize"] |
318 | | options["url"] = options["u"] or options["url"] or defaults["url"] |
319 | | |
320 | | options["logo"] = options["l"] or options["logo"] |
321 | | if options["logo"] is None : # Allows --logo="" to disable the logo entirely |
322 | | options["logo"] = defaults["logo"] |
323 | | |
324 | | if options["help"] : |
325 | | banner.display_usage_and_quit() |
326 | | elif options["version"] : |
327 | | banner.display_version_and_quit() |
328 | | else : |
329 | | retcode = banner.main(args, options) |
| 283 | retcode = banner.main(arguments, options) |