[spambayes-dev] Re: proposal for more uniform option setting from the command line

Skip Montanaro skip at pobox.com
Wed Nov 12 17:13:34 EST 2003


    me> How about instead of only allowing specific options to be overridden
    me> on the command line we use a consistent syntax for overriding *any*
    me> option from the command line?

I took the first step in this direction, adding a set_from_cmdline method to
OptionsClass.OptionsClass and modifying sb_filter.py to accept -o/--option
flags.  Seems to work for me.  I decided to push as much processing into
OptionsClass.py as possible (including error message display) to make it as
easy as possible to process these options from other apps.  In sb_filter.py,
I had to add 'o:' and 'option=' to the appropriate getopt.getopt() arg and
add

        elif opt in ('-o', '--option'):
            Options.options.set_from_cmdline(arg, sys.stderr)

to the post-getopt() call processing.  If you want to handle error recovery
yourself, simply omit the sys.stderr arg from the call and wrap the call in
the appropriate try/except incantation.  Note that the way I have it set up,
it displays the error but continues processing.  I don't know if that's
necessarily a good way to do it, but under the assumption that this is
mostly for propeller head use, it seems okay to let processing continue and
thus be able to potentially catch multiple errors.

Skip



More information about the spambayes-dev mailing list