-
Notifications
You must be signed in to change notification settings - Fork 18
/
itemGrep.py
56 lines (49 loc) · 1.25 KB
/
itemGrep.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import bcsv
import specs
import sys
import json
b = bcsv.File(specs.ItemParam)
b.load(open('../ac120upd/romfs/Bcsv/ItemParam.bcsv', 'rb').read())
stuff = json.load(open('savefile/editor/gameData.json', 'r'))
pall = False
if '-all' in sys.argv:
sys.argv.remove('-all')
pall = True
def getname(iid):
try:
return stuff['items'][str(iid)]
except KeyError:
return '???'
def prow(row):
if pall:
for fld in row.fields():
print(f'{fld} -> {getattr(row,fld)}')
else:
print(f'{row.UniqueID} - {row.Label} - {getname(row.UniqueID)}')
mode = sys.argv[1]
if mode == 'agg':
key = sys.argv[2]
agg = {}
for row in b.rows:
val = getattr(row, key)
if val in agg:
agg[val].append(row)
else:
agg[val] = [row]
for key,rows in agg.items():
print(f'[{key}] ({len(rows)})')
for row in rows:
prow(row)
elif mode == 'eq':
key = sys.argv[2]
for row in b.rows:
if row._c353ef20 < 65535:
prow(row)
elif mode == 'id':
for key in sys.argv[2:]:
if key.startswith('0x'):
ikey = int(key[2:], 16)
else:
ikey = int(key)
if ikey in b.by_id:
prow(b.by_id[ikey])