oasislmf.utils.inputs¶
Classes¶
Helper class for accessing the input values from either |
Functions¶
|
|
|
|
|
|
|
Func type for loading strings to boolean values using argparse |
Module Contents¶
- class oasislmf.utils.inputs.InputValues(args, update_keys=True)[source]¶
Bases:
objectHelper class for accessing the input values from either the command line or the configuration file.
internal_update
- get(name, default=None, required=False, is_path=False, dtype=None)[source]¶
- Gets the name parameter until found from:
the command line arguments.
the configuration file
the environment variable (put in uppercase)
If it is not found then
defaultis returned unlessrequiredis True in which case anOasisExceptionis raised.- Parameters:
name (str) – The name of the parameter to lookup
default – The default value to return if the name is not found on the command line or in the configuration file.
required (bool) – Flag whether the value is required, if so and the parameter is not found on the command line or in the configuration file an error is raised.
is_path (bool) – Flag whether the value should be treated as a path and return an abspath, use config_dir as base dir if value comes from the config
dtype – the class <type> of the value, if ‘None’ load as string by default
- Type:
class
- Raises:
OasisException – If the value is not found and
requiredis True- Returns:
The found value or the default
- oasislmf.utils.inputs.str2bool(v)[source]¶
Func type for loading strings to boolean values using argparse https://stackoverflow.com/a/43357954
- step_params:
use: ‘default’: False, ‘type’: str2bool, ‘const’:True, ‘nargs’:’?’, …
- CLI:
oasislmf –some-flag oasislmf –some-flag <bool>
oasislmf.json {“some_flag”: true, …}