qgis_deployment_toolbelt.utils.str2bool module

Basic string to bool.

qgis_deployment_toolbelt.utils.str2bool.str2bool(input_var: bool | str, raise_exc: bool = False) bool | None

Determine if a string is a bool and, if so, convert it.

Parameters:
  • input_var (str) – value to convert

  • raise_exc (bool, optional) – strict mode, defaults to False. Defaults to False.

Raises:
  • ValueError – input_var is not in true and false sets

  • TypeError – if input_var is not a str or a bool

Returns:

True if input_var is in _true_set, False if it’s in _false_set.

Return type:

bool

None or Exception if not in any of two sets.