-
Notifications
You must be signed in to change notification settings - Fork 5
/
guano_dump.py
executable file
·50 lines (37 loc) · 1.12 KB
/
guano_dump.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
#!/usr/bin/env python
"""
Print the GUANO metadata found in a file or files.
usage::
$> guano_dump.py [--strict] WAVFILE...
"""
from __future__ import print_function
import sys
import os
import os.path
from guano import GuanoFile
def dump(fname, strict=False):
print()
print(fname)
gfile = GuanoFile(fname, strict=strict)
print(gfile.to_string())
if __name__ == '__main__':
from glob import glob
import logging
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s\t%(levelname)s\t%(message)s')
if len(sys.argv) < 2:
print('usage: %s [--strict] FILE...' % os.path.basename(sys.argv[0]), file=sys.stderr)
sys.exit(2)
if os.name == 'nt' and '*' in sys.argv[1]:
fnames = glob(sys.argv[1])
else:
fnames = sys.argv[1:]
strict = False
if '--strict' in fnames:
fnames.remove('--strict')
strict = True
for fname in fnames:
if os.path.isdir(fname):
for subfname in glob(os.path.join(fname, '*.[Ww][Aa][Vv]')):
dump(subfname, strict=strict)
else:
dump(fname, strict=strict)