Skip to content

Instantly share code, notes, and snippets.

@RaD
Created November 8, 2019 09:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RaD/5714271b6a7d1594b133315919e92825 to your computer and use it in GitHub Desktop.
Save RaD/5714271b6a7d1594b133315919e92825 to your computer and use it in GitHub Desktop.
import json
path_src = './references/migrations/0004_speciality.json'
path_dst = './references/migrations/0004_speciality.json'
src = open(path_src, 'r')
dst = open(path_dst, 'w')
payload = json.loads(src.read())
result = []
index = 0
for i in payload:
i['fields']['level'] = 0
i['fields']['tree_id'] = 1
index += 1
i['fields']['lft'] = index
index += 1
i['fields']['rght'] = index
result.append(i)
dst.write(json.dumps(result))
src.close()
dst.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment