OptionLoader
- class sane.options.OptionLoader[source]
Bases:
Logger- load_core_options(options, origin=None)[source]
Any processed field should be removed from the options dict, with everything else ignored. All listed options are cummulative and optional unless specified otherwise.
See
load_options()for parameters.
- load_extra_options(options, origin=None)[source]
Load any extra options after
load_core_options().Any processed field should be removed from the options dict, with everything else ignored.
See
load_options()for parameters.
- load_options(options, origin=None)[source]
Base class implementation for loading of dict-based attributes into instance
Take a options dict of relevant attributes and load them via
load_core_options()thenload_extra_options(). The options dict should be modified in each call to remove processed fields so that at the very end of this method, any unused keys in the options dict may be logged.The
load_extra_options()is meant as a user-overwritable method so thatload_core_options()may retain core underlying base class implementation details without the risk of base class loading not being called.To keep track of every time this function is called and potentially modifying this instance an origin may be provided, noting where the change is coming from.
- property origins
A copy of all the workflow file paths (and line numbers if applicable) that formed this object
- search_type(type_str, noexcept=False)[source]
Match a type (as an input string) to an actualy python
typeIf at any point a search is successful, the function immediately returns the found
type.Search priority:
type_strusingpydoclocate()(effectively search current context for type of that fully qualified name )Split
type_stron last.in name and search any user-loaded module that contains the prefix for an attribute matching the suffix. If no split occurs all user modules are searched.
Valid type examples:
import sane import user_mod.nested.foo # module foo has CustomType # ... in the context of this class ... self.search_type( "sane.Action" ) self.search_type( "sane.host.Host" ) self.search_type( "user_mod.nested.foo.CustomType" ) # Using search method (2) if foo was loaded into the user modules by the workflow # since "foo" is a substring of "user_mod.nested.foo" self.search_type( "foo.CustomType" )