GNOME Bugzilla – Bug 469763
Use OptionParser to parse options
Last modified: 2012-02-10 08:08:08 UTC
In the patch below, I have replaced codegen.py's getopt based option parsing with OptionParser. There are no feature changes but some nicities added: before: $ python codegen.py usage: codegen.py [-o overridesfile] [-p prefix] defsfile after: $ python codegen.py usage: codegen.py [options] defsfile options: -o OVERRIDE, --override=OVERRIDE overrides file -p PREFIX, --prefix=PREFIX prefix for variable names inside generated code -r REGISTER, --register=REGISTER file with types to register --outfilename=OUTFILENAME c file to generate --errorfilename=ERRORFILENAME file to log errors to --py_ssize_t_clean set py_ssize_t_clean -D DEFINES add preprocessor definition key-value -I INCLUDES add include path -t LOAD_TYPES, --load-types=LOAD_TYPES script to load before code generation -h, --help show this help message and exit The option descriptions might not be 100% correct, I had to make educated guesses at what the undocumented options do. There is also some more exception handling so you should (in more cases) get an error message instead of a traceback when a file is missing. I cannot swear that the patch doesn't break something, but I've tried running it on some examples and it seems to work ok. So someone else should try it too. It incidentally solves the silent error "python codegen.py -r foobar.defs -DMOO=BOO" since OptionParser-parsing is position independent.
Created attachment 94228 [details] [review] Replace getopt with OptionParser, provide nice help page
codegen is obsolete with pygobject 3.0, which is GI only.