forked from tracek/Ornithokrites
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfiguration.py
35 lines (26 loc) · 1.32 KB
/
configuration.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
# -*- coding: utf-8 -*-
"""
Created on Wed Feb 26 08:56:34 2014
@author: Lukasz Tracewski
Module for parsing user input
"""
from collections import namedtuple
from argparse import ArgumentParser
AppConfig = namedtuple('AppConfig', ['data_store', 'bucket', 'write_stdout'])
class Configurator(object):
def __init__(self):
self._parser = ArgumentParser(description='Automatic identification of kiwi calls from audio recordings',
prog='Ornithokrites', epilog='lukasz.tracewski@gmail.com')
self._parser.add_argument('-b', '--bucket', help='Amazon Web Services S3 bucket name')
self._parser.add_argument('-d', '--datastore', help='Directory to process')
self._parser.add_argument('--stdout', help='Print messages to standard output', action='store_true')
def parse_arguments(self):
args = self._parser.parse_args()
if args.bucket: # Web Interface
if args.datastore:
self.Data_Store = args.datastore
else:
self.Data_Store = '/var/www/results/Recordings/' # default for the Web Interface
elif args.datastore: # Command-line batch mode
self.Data_Store = args.datastore
return AppConfig(self.Data_Store, args.bucket, args.stdout)