code: def _generate_states_report(sorted_data):
      '''
      Generate states report
      '''
      states = []
      for state, data in sorted_data:
          module, stateid, name, function = state.split('_|-')
          module_function = '.'.join((module, function))
          result = data.get('result', '')
          single = [
              {'function': module_function},
              {'name': name},
              {'result': result},
              {'duration': data.get('duration', 0.0)},
              {'comment': data.get('comment', '')}
          ]
  
          if not result:
              style = 'failed'
          else:
              changes = data.get('changes', {})
              if changes and isinstance(changes, dict):
                  single.append({'changes': _dict_to_name_value(changes)})
                  style = 'changed'
              else:
                  style = 'unchanged'
  
          started = data.get('start_time', '')
          if started:
              single.append({'started': started})
  
          states.append({stateid: single, '__style__': style})
      return statef _generate_states_report(sorted_data):
      '''
      Generate states report
      '''
      states = []
      for state, data in sorted_data:
          module, stateid, name, function = state.split('_|-')
          module_function = '.'.join((module, function))
          result = data.get('result', '')
          single = [
              {'function': module_function},
              {'name': name},
              {'result': result},
              {'duration': data.get('duration', 0.0)},
              {'comment': data.get('comment', '')}
          ]
  
          if not result:
              style = 'failed'
          else:
              changes = data.get('changes', {})
              if changes and isinstance(changes, dict):
                  single.append({'changes': _dict_to_name_value(changes)})
                  style = 'changed'
              else:
                  style = 'unchanged'
  
          started = data.get('start_time', '')
          if started:
              single.append({'started': started})
  
          states.append({stateid: single, '__style__': style})
      return states
docs: Generate states report