def OrganizeFindingsByFile(findings_list):
  """Creates dict mapping filepath to all findings in that file.

  Args:
    findings_list: a list of Finding objects.

  Returns:
    A dict. Keys are filepath strings and values are a list of findings
      that are associated with that filepath.
  """
  file_findings_map = {}
  for finding in findings_list:
    filepath = finding.file_context.filepath
    file_list = file_findings_map.get(filepath)
    # not in map: add as new entry
    if file_list is None:
      file_findings_map[filepath] = [finding]
    # if already in map, append this finding to associated value
    else:
      file_findings_map[filepath].append(finding)

  return file_findings_map