-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathupdate_directory.py
37 lines (31 loc) · 1.18 KB
/
update_directory.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
import os
import json
blacklist = [
'demiiial/marie', # color map too messy; index overlap with face and hair
'krazete/n_ko_avatar_filia' # cropped; replaced with full version by n_ko
]
def update_directory():
'''Updates directory.js with contents of sprite folder.'''
directory = {}
for path in os.listdir('sprite'):
if os.path.isdir(path) or path == 'cat.png':
continue
filename = path.split('.')[0]
character = filename.split('_')[0].lower()
if character == 'heavymetal':
character = 'bigband'
directory.setdefault(character, [])
directory[character].append(filename)
directory.setdefault('custom', [])
for path in os.listdir('sprite/custom'):
for subpath in os.listdir('sprite/custom/{}'.format(path)):
name = '{}/{}'.format(path, '.'.join(subpath.split('.')[0:-1]))
if name in blacklist:
continue
directory['custom'].append('custom/{}'.format(name))
with open('directory.js', 'w') as fp:
fp.write('var ids = ')
json.dump(directory, fp, indent=4)
fp.write(';\n')
if __name__ == '__main__':
update_directory()