Table of Contents

Class: KeywordOrBooleanArg Gnuplot/termdefs.py

Allow a keyword arg to be specified either as a keyword or a boolean.

This arg type is the most flexible way to allow keyword parameters to be specified. Say there is an option like fontsize that can take the values small or large. This could be represented as

KeywordOrBooleanArg(options=["small", "large"], argname="fontsize")

In that case, the fontsize could be specified in any of the following ways:

g.hardcopy(..., fontsize="small", ...) g.hardcopy(..., fontsize="large", ...) g.hardcopy(..., small=1, ...) g.hardcopy(..., large=1, ...)

If argname is set to be None, then the first two possibilities are omitted.

In the special case that there are exactly two alternatives, one can also use:

g.hardcopy(..., small=0, ...) # implies fontsize="large" g.hardcopy(..., large=0, ...) # implies fontsize="small"

Obviously care must be taken to ensure that none of the implied keyword parameter names conflict with one another or with any of the other Args allowed by a function.

Members:

options
a list of strings representing allowed keyword values. These options can be used as boolean values in the style option=1.
argname
the name of the argname for the arg=value style of setting the argument. If None, then this style is not allowed.
fixedword
a fixed keyword that must precede the option, or None.
default
the default option to set if nothing is set explicitly, or None to leave nothing set in that case.
Base Classes   
Arg
Methods   
__call__
__init__
  __call__ 
__call__ ( self,  keyw )

Exceptions   
Errors.OptionError('Arguments %s and %s are contradictory' %( self.argname, k, ) )
Errors.OptionError('Arguments %s and %s cannot both be specified' %( option, k, ) )
Errors.OptionError('Illegal option %s=%s' %( self.argname, k, ) )
  __init__ 
__init__ (
        self,
        options,
        argname=None,
        fixedword=None,
        default=None,
        )


Table of Contents

This document was automatically generated on Sun Oct 19 17:10:22 2003 by HappyDoc version 2.1