roboglia.utils.check_options

check_options(value, options, context, context_id, logger, message=None)[source]

Checks if a value is in a list of allowed options.

Parameters
  • value (any) – a value to be checked

  • options (list) – the allowed options for the value

  • context (str) – a string indicating the context of the check, for example ‘Bus’ or ‘Device’

  • context_id (str or int) – indicates the precise context (the name of the object or, in case the key we are searching is the name we will have to use the index of the item in the initialization dictionary)

  • logger (logger object) – where the logging will be written

  • message (str) – if this is provided the function will use this message for logging and raise instead of building a message specific for the context.

Raises

ValueError – if the value is not in the allowed options