import io import subprocess import whoowns import argparse def main(): parser = argparse.ArgumentParser(description="Generates a CSV of all files in the repo and which codeowner is set.") parser.add_argument("out") args = parser.parse_args() owners = whoowns.get_owners('./CODEOWNERS') file = io.open(args.out, "w", encoding="utf-8") file.write("path,owners\n") all_files = subprocess.run(["git", "ls-files"], capture_output=True, text=True).stdout.split('\n') for path in all_files: file_owners = owners.of(path) file.write("%s,%s\n" % (path, " ".join(map(lambda o: o[1], file_owners)))) file.flush() file.close() if __name__ == "__main__": main()