drakul/migrate.py

25 lines
786 B
Python

import json
with open("data.json", "r") as file:
data = json.load(file)
for o in data:
print(o)
if o["model"] == "raids.raidresponse":
if o["fields"]["status"] >= 2: # SIGNED_UP
o["fields"]["attendance"] = 1.0
else:
o["fields"]["attendance"] = 0.0
if o["model"] == "users.user":
o["fields"]["rank"] = 3 # veteran
print("=============================================")
print("=============================================")
print("=============================================")
with open("new.json", "w") as file:
skip = ["contenttypes.contenttype", "auth.permission", "admin.logentry"]
thedump = [d for d in data if d["model"] not in skip]
for d in thedump:
print(d)
json.dump(thedump, file)