forked from philipperemy/deep-speaker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconstants.py
35 lines (26 loc) · 875 Bytes
/
constants.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
import json
import logging
import os
import namedtupled
logger = logging.getLogger(__name__)
CONFIGURATION_FILENAME = 'conf.json'
def filename_to_named_tuple(filename):
with open(filename) as data_file:
c_ = json.load(data_file)
# pprint(c_)
return namedtupled.map(c_)
def load_constants():
c_ = None
try:
c_ = filename_to_named_tuple(CONFIGURATION_FILENAME)
except FileNotFoundError as e:
try:
c_ = filename_to_named_tuple(os.path.join('..', CONFIGURATION_FILENAME))
except FileNotFoundError as e:
try:
c_ = filename_to_named_tuple(os.path.join('..', '..', CONFIGURATION_FILENAME))
except:
logger.error(e)
logger.error('Please execute this command: cp conf.json.example conf.json')
return c_
c = load_constants()