forked from CPJKU/madmom
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPickleProcessor
executable file
·50 lines (36 loc) · 1.29 KB
/
PickleProcessor
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
# encoding: utf-8
"""
PickleProcessor.
"""
from __future__ import absolute_import, division, print_function
import argparse
import pickle
from madmom.processors import io_arguments
def main():
"""PickleProcessor."""
# define parser
parser = argparse.ArgumentParser(
formatter_class=argparse.RawDescriptionHelpFormatter, description='''
This program runs previously pickled Processors in either 'single' or
'batch' mode.
$ PickleProcessor PROCESSOR single INFILE [-o OUTFILE]
$ PickleProcessor PROCESSOR batch FILES
To obtain a pickled Processor, either run the respective program with the
'pickle' option or call the 'dump()' method of the Processor.
''')
# add options
parser.add_argument('processor', type=argparse.FileType('rb'),
help='pickled processor')
parser.add_argument('--version', action='version',
version='PickleProcessor v0.1')
io_arguments(parser, output_suffix='.txt', pickle=False)
# parse arguments
args = parser.parse_args()
kwargs = vars(args)
# create a processor
processor = pickle.load(kwargs.pop('processor'))
# and call the processing function
args.func(processor, **kwargs)
if __name__ == '__main__':
main()