-
Notifications
You must be signed in to change notification settings - Fork 1
/
reformat.py
36 lines (24 loc) · 1.04 KB
/
reformat.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import json
import os
count = 0
for root_dir, cur_dir, files in os.walk(r'<Your_directory_path_that_contain_all_the_json_to_update>'):
count += len(files)
print('file count:', count)
for i in range(count):
with open(f'out/{i}.json') as f:
data = json.load(f)
data['token_uri']=f'https://.../{i}.json'
data['token_id']=f'{i}'
data['animation_url']='null'
data['royalty_percentage']='null'
data['royalty_payment_address']='null'
# data['extension']={}
for item in data['attributes']:
item['trait_type'] = item['trait_type'].replace('Mask', 'Face')
item['trait_type'] = item['trait_type'].replace('Body', 'Clothes')
item['trait_type'] = item['trait_type'].replace('Head', 'Headwear')
item['trait_type'] = item['trait_type'].replace('Flying Objects', 'Special Items')
item['trait_type'] = item['trait_type'].replace('Neclaces', 'Necklace')
with open(f'new_json/{i}.json', 'w') as f:
json.dump(data, f)
f.close()