Base class for named objects that support Parameters and message formatting.
Automatic object naming: Every ParameterizedObject has a name
parameter. If the user doesn't designate a name=<str> argument
when constructing the object, the object will be given a name
consisting of its class name followed by a unique 5-digit number.
Automatic parameter setting: The ParameterizedObject __init__
method will automatically read the list of keyword parameters. If
any keyword matches the name of a Parameter (see Parameter class)
defined in the object's class or any of its superclasses, that
parameter in the instance will get the value given as a keyword
argument. For example:
in this case foo.xx gets the value 20.
Message formatting: Each ParameterizedObject has several methods
for optionally printing output according to the current 'print
level', such as SILENT, WARNING, MESSAGE, VERBOSE, or DEBUG. Each
successive level allows more messages to be printed. For example,
when the level is VERBOSE, all warning, message, and verbose
output will be printed. When it is WARNING, only warnings will be
printed. When it is SILENT, no output will be printed.
For each level (except SILENT) there's an associated print method:
ParameterizedObject.warning(), .message(), .verbose(), and .debug().
Each line printed this way is prepended with the name of the
object that printed it. The ParameterizedObject parameter
print_level, and the module global variable min_print_level
combine to determine what gets printed. For example, if foo is a
ParameterizedObject:
|
|
__db_print(self,
level=100,
*args)
Print each of the given args iff print_level or
self.db_print_level is greater than or equal to the given
level. |
source code
|
|
|
|
|
|
|
__getstate__(self)
Save the object's state: return a dictionary that is a shallow
copy of the object's __dict__. |
source code
|
|
|
|
|
|
|
__repr__(self)
Provide a nearly valid Python representation that could be used to recreate
the item with its parameters, if executed in the appropriate environment. |
source code
|
|
|
|
|
|
|
__str__(self)
Return a short representation of the name and class of this object. |
source code
|
|
|
|
_check_params(self,
params)
Print a warning if params contains something that is
not a Parameter of this object. |
source code
|
|
|
|
| _instantiate_param(self,
param_obj,
dict_=None,
key=None) |
source code
|
|
|
|
|
|
|
|
|
|
as_uninitialized(fn)
Decorator: call fn with the instance's initialization flag set
to False, then revert the flag. |
source code
|
|
|
|
debug(self,
*args)
Print the arguments as a debugging statement. |
source code
|
|
|
|
defaults(self)
Return {parameter_name:parameter.default} for all non-constant
Parameters. |
source code
|
|
|
|
|
|
|
get_param_values(self,
onlychanged=False)
Return a list of name,value pairs for all Parameters of this object |
source code
|
|
|
|
|
|
|
|
|
|
message(self,
*args)
Print the arguments as a message. |
source code
|
|
|
|
print_param_values(self)
Print the values of all this object's Parameters. |
source code
|
|
|
|
script_repr(self,
imports=[],
prefix=' ')
Variant of __repr__ designed for generating a runnable script. |
source code
|
|
|
|
verbose(self,
*args)
Print the arguments as a verbose message. |
source code
|
|
|
|
warning(self,
*args)
Print the arguments as a warning, unless module variable
warnings_as_exceptions is True, then raise an Exception
containing the arguments. |
source code
|
|
|
Inherited from object:
__delattr__,
__getattribute__,
__hash__,
__new__,
__reduce__,
__reduce_ex__,
__setattr__
|