-
-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
migrations: add script to remove file hashes
- Loading branch information
Showing
1 changed file
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |