-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.py
executable file
·43 lines (34 loc) · 1.15 KB
/
build.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
#!/usr/bin/env python
'''Index data files for distribution'''
from pathlib import Path
import pooch
import json
def main():
# Build the pooch registry
regfile = Path('index') / Path('registry.txt')
pooch.make_registry('audio', regfile)
# Parse the registry into the keyword manifest
tracks = set()
with open(regfile, 'r') as fd:
for line in fd:
base = line.split('.', 2)[0]
tracks.add(base)
keymap = Path('index') / Path('index.json')
if keymap.exists():
with open(keymap, 'r') as fd:
trackmap = json.load(fd)
else:
trackmap = dict()
known_tracks = set(t['path'] for t in trackmap.values())
for track in tracks:
if track not in known_tracks and track != "version_index":
try:
key = input('Enter a key for {}: '.format(track))
desc = input('Enter a description for {}: '.format(track))
trackmap[key] = dict(path=track, desc=desc)
except KeyboardInterrupt:
pass
with open(keymap, 'w') as fd:
json.dump(trackmap, fd)
if __name__ == '__main__':
main()