-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmake.py
More file actions
33 lines (27 loc) · 1.11 KB
/
Copy pathmake.py
File metadata and controls
33 lines (27 loc) · 1.11 KB
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
import re
import os
import sys
import json
currentPath = sys.path[0]
itemPath = os.path.join(currentPath, 'items')
itemsJson = 'items.json'
if not os.path.exists(itemPath):
os.makedirs(itemPath)
with open(os.path.join(currentPath, 'items.json')) as f:
data = json.load(f)
del data['?xml']
del data['items']['@xmlns:xsi']
del data['items']['@xsi:noNamespaceSchemaLocation']
del data['items']['shopcategories']
itemWeights = {}
for itemType in data['items']:
if type(data['items'][itemType]) is dict:
if {'@uniquename','@weight'} <= data['items'][itemType].keys():
with open(os.path.join(itemPath, data['items'][itemType]['@uniquename']), 'w', encoding='utf-8') as f:
f.write(data['items'][itemType]['@weight'])
elif type(data['items'][itemType]) is list:
length = len(data['items'][itemType])
for i in range(length):
if {'@uniquename','@weight'} <= data['items'][itemType][i].keys():
with open(os.path.join(itemPath, data['items'][itemType][i]['@uniquename']), 'w', encoding='utf-8') as f:
f.write(data['items'][itemType][i]['@weight'])