# Confiurations

## Configuration

class canlib.kvamemolibxml.Configuration(xml=None, lif=None)

  Configuration data for Kvaser devices

  It is usually preferred to create objects of this class with one of the functions:

  - `load_xml`

  - `load_xml_file`

  - `load_lif`

  - `load_lif_file`

  The XML and param.lif representation of this configuration can be accessed with the `xml` and `lif` attributes, respectively.

  Two `Configuration` objects can be tested for equality:

      config1 == config2

  This will test whether the objects are equivalent: whether they have the same param.lif representation.

  Finally, the configuration can be validated with `Configuration.validate`:

      errors, warnings = configuration.validate()
      for error in errors:
          print(error)
      for warning in warnings:
          print(warning)
      if errors:
          raise ValueError("Invalid configuration")

  property lif

    The param.lif representation of this configuration

    Type

      `bytes`

  validate()

    Validate this configuration

    Validates the XML representation of this configuration, and returns a tuple `(errors, warnings)` where `errors` is a `list` of `ValidationError` and `warnings` is a `list` `ValidationWarning`.

  property xml

    The XML representation of this configuration

    Type

      `str`

## load_lif()

canlib.kvamemolibxml.load_lif(lif_bytes)

  Create a `Configuration` from a param.lif `bytes`

  Parameters

    lif_bytes (`bytes`) – Binary configuration in param.lif format

## load_lif_file()

canlib.kvamemolibxml.load_lif_file(filepath)

  Like `load_lif` but takes a path to a file containing the lif configuration

## load_xml()

canlib.kvamemolibxml.load_xml(xml_string)

  Create a `Configuration` from an xml `string`

  Parameters

    xml_string (`str`) – XML configuration

## load_xml_file()

canlib.kvamemolibxml.load_xml_file(filepath)

  Like `load_lif` but takes a path to a file containing the XML configuration

## ValidationMessage

class canlib.kvamemolibxml.ValidationMessage(code, text)

  Validation code and message.

  Parameters

    - code (`int`) – Valdiation status code.

    - text (`str`) – Validation message.

  property code

    Alias for field number 0

  property text

    Alias for field number 1

## ValidationErrorMessage

class canlib.kvamemolibxml.ValidationErrorMessage(code, text)

  An error found during validation

## ValidationWarningMessage

class canlib.kvamemolibxml.ValidationWarningMessage(code, text)

  A warning found during validation