oasislmf.utils.inputs ===================== .. py:module:: oasislmf.utils.inputs Classes ------- .. autoapisummary:: oasislmf.utils.inputs.InputValues Functions --------- .. autoapisummary:: oasislmf.utils.inputs.update_config oasislmf.utils.inputs.has_oasis_env oasislmf.utils.inputs.get_oasis_env oasislmf.utils.inputs.str2bool Module Contents --------------- .. py:function:: update_config(config_data, config_map=get_config_profile()) .. py:function:: has_oasis_env(name) .. py:function:: get_oasis_env(name, dtype=None, default=None) .. py:class:: InputValues(args, update_keys=True) Bases: :py:obj:`object` Helper class for accessing the input values from either the command line or the configuration file. internal_update .. py:attribute:: logger .. py:attribute:: args .. py:attribute:: config .. py:attribute:: config_fp .. py:attribute:: config_mapping .. py:method:: list_unknown_keys() List all Unknown keys set in the 'oasislmf.json' file .. py:method:: load_config_file() .. py:method:: write_config_file(config_fp) .. py:method:: confirm_action(question_str, no_confirm=False) .. py:method:: get(name, default=None, required=False, is_path=False, dtype=None) 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 ``default`` is returned unless ``required`` is True in which case an ``OasisException`` is raised. :param name: The name of the parameter to lookup :type name: str :param default: The default value to return if the name is not found on the command line or in the configuration file. :param required: 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. :type required: bool :param is_path: 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 :type is_path: bool :param dtype: the class of the value, if 'None' load as string by default :type: class :raise OasisException: If the value is not found and ``required`` is True :return: The found value or the default .. py:function:: str2bool(v) 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 oasislmf.json {"some_flag": true, ...}