Clean up .py scripts
This commit is contained in:
parent
56c97115e2
commit
2d3bd212e7
3 changed files with 0 additions and 77 deletions
25
scripts/cleanup.py
Normal file
25
scripts/cleanup.py
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
"""
|
||||
Cleans up existing datapack files to replace empty / {} files with properly formatted
|
||||
empty recipes.
|
||||
"""
|
||||
|
||||
import json
|
||||
import os
|
||||
|
||||
for root, dirs, files in os.walk("./data"):
|
||||
for file in files:
|
||||
try:
|
||||
with open(f"{root}/{file}", "r", encoding="utf-8") as fh:
|
||||
raw_data = fh.read().strip()
|
||||
if raw_data and json.loads(raw_data) != {}:
|
||||
print(f"Skipped {root}/{file} - has content")
|
||||
continue
|
||||
data = {
|
||||
"type": "minecraft:crafting_shapeless",
|
||||
"ingredients": [{"item": "minecraft:air"}],
|
||||
"result": {"item": "minecraft:air"},
|
||||
}
|
||||
with open(f"{root}/{file}", "w", encoding="utf-8") as fh:
|
||||
fh.write(json.dumps(data))
|
||||
except Exception as exc:
|
||||
print(f"Failed to clean {root}/{file}: {exc}")
|
||||
Loading…
Reference in a new issue