options

Utilities and type processors for module options.

opt_type_help(help_text)[source]

Decorator to add help text to functions that are designed to be used as module option processors. The help text will be used to describe the type in documentation.

opt_type_example(example_text)[source]

Decorate to add an example value to function that are designed to be used as module option processors. The given text will be used in module docs as an example of how to specify the option in a config file.

format_option_type(t)[source]
str_to_bool(string)[source]

Convert a string value to a boolean in a sensible way. Suitable for specifying booleans as options.

Parameters:string – input string
Returns:boolean value
choose_from_list(options, name=None)[source]

Utility for option processors to limit the valid values to a list of possibilities.

comma_separated_list(item_type=<class 'str'>, length=None)[source]

Option processor type that accepts comma-separated lists of strings. Each value is then parsed according to the given item_type (default: string).

comma_separated_strings(string)
json_string(string)[source]
json_dict(string)[source]

JSON dicts, with or without {}s

process_module_options(opt_def, opt_dict, module_type_name)[source]

Utility for processing runtime module options. Called from module base class.

Also used when loading a dataset’s datatype from datatype options specified in a config file.

Parameters:
  • opt_def – dictionary defining available options
  • opt_dict – dictionary of option values
  • module_type_name – name for error output
Returns:

dictionary of processed options

exception ModuleOptionParseError[source]

Bases: Exception