Created
November 8, 2019 09:28
-
-
Save RaD/5714271b6a7d1594b133315919e92825 to your computer and use it in GitHub Desktop.
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
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