get_sha256_hashes.py 983 B

12345678910111213141516171819202122232425262728293031323334
  1. """Compute sha256 hashes for all files"""
  2. import os
  3. import pooch
  4. def append_file(source_file_path, destination_file_path):
  5. """Append contents of source file into destination file."""
  6. # Read the contents of the source file
  7. with open(source_file_path, "r") as source_file:
  8. source_contents = source_file.read()
  9. # Open the destination file in append mode and write
  10. with open(destination_file_path, "a") as destination_file:
  11. destination_file.write(source_contents)
  12. def main():
  13. folders = ["ml-runs", "04.09.2023-04-Right_RE_test_3_frames"]
  14. destination_file = "files-registry.txt"
  15. for folder in folders:
  16. # write registry for current folder in temporary file
  17. pooch.make_registry(folder, f"out_{folder}")
  18. # append temporary file to destination file
  19. append_file(f"out_{folder}", destination_file)
  20. # remove temporary file
  21. os.remove(f"out_{folder}")
  22. if __name__ == "__main__":
  23. main()