code: def build_messages_modules(messages):
      data = collections.defaultdict(list)
      for line in messages:
          module_name = line.get('module')
          module_path = line.get('path')
          module_info = ModuleInfo(
              module_name,
              module_path,
          )
          data[module_info].append(line)
      for module, module_messages in data.items():
          yield (
              module,
              sorted(module_messages, key=lambda x: x.get('line')))