Skip to content

Commit

Permalink
migrations: add script to remove file hashes
Browse files Browse the repository at this point in the history
  • Loading branch information
avivace committed Jul 31, 2023
1 parent 2d5da8a commit 4dc1880
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions scripts/2_remove_hashes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
"""
Change entries with "homebrew" as typetag to "tool"
"""

import json
import os

entries_list = os.listdir("../entries")
mock = False

for entry in entries_list:
with open(f"../entries/{entry}/game.json", "r+") as f:
changes = False
manifest = json.load(f)

new_files = []

for file in manifest["files"]:
if "hash" in file:
print(
f"Removing hashes in file {file['filename']} (entry {manifest['slug']})"
)
changes = True
file.pop("hash")
new_files.append(file)

if not mock and changes is True:
manifest["files"] = new_files
f.seek(0) # <--- should reset file position to the beginning.
json.dump(manifest, f, indent=4, ensure_ascii=False)
f.truncate() # remove remaining part

0 comments on commit 4dc1880

Please sign in to comment.