blob: d17c63a96ff50fab4dfc4487bca9e6c67eb8146b [file] [log] [blame]
gstepanovc82391e2015-03-17 15:46:36 +02001import yaml
gstepanov725cc302015-02-09 15:08:06 +02002import os
3
stgleb75c70412015-02-17 02:52:00 +02004
gstepanovc82391e2015-03-17 15:46:36 +02005def parse_config(file_name):
6 with open(file_name) as f:
7 cfg = yaml.load(f.read())
8
9 return cfg
10
11
gstepanov5f936df2015-03-18 19:15:59 +020012parser = argparse.ArgumentParser(description="config file name")
13parser.add_argument("-p", "--path")
gstepanovb3c78962015-03-20 15:47:58 +020014parser.add_argument("-b", "--basedir")
15parser.add_argument("-t", "--testpath")
16parser.add_argument("-d", "--database")
17parser.add_argument("-c", "--chartpath")
gstepanov5f936df2015-03-18 19:15:59 +020018
19config = parser.parse_args(sys.argv[1:])
20path = "config.yaml"
21
22if not config.path is None:
23 path = config.path
24
25cfg_dict = parse_config(os.path.join(os.path.dirname(__file__), path))
gstepanovc82391e2015-03-17 15:46:36 +020026basedir = cfg_dict['paths']['basedir']
27TEST_PATH = cfg_dict['paths']['TEST_PATH']
28SQLALCHEMY_MIGRATE_REPO = cfg_dict['paths']['SQLALCHEMY_MIGRATE_REPO']
29DATABASE_URI = cfg_dict['paths']['DATABASE_URI']
gstepanov5f936df2015-03-18 19:15:59 +020030CHARTS_IMG_PATH = cfg_dict['paths']['CHARTS_IMG_PATH']
31
gstepanovb3c78962015-03-20 15:47:58 +020032if not config.basedir is None:
33 basedir = config.basedir
34
35if not config.testpath is None:
36 TEST_PATH = config.testpath
37
38if not config.database is None:
39 DATABASE_URI = config.database
40
41if not config.chartpath is None:
42 CHARTS_IMG_PATH = config.chartpath
43
gstepanov5f936df2015-03-18 19:15:59 +020044