blob: 6dd1a9b0f58c9604dd3280e61e9bd735ae79b165 [file] [log] [blame]
gstepanov5f936df2015-03-18 19:15:59 +02001import argparse
2import sys
gstepanovc82391e2015-03-17 15:46:36 +02003import yaml
gstepanov725cc302015-02-09 15:08:06 +02004import os
5
stgleb75c70412015-02-17 02:52:00 +02006
gstepanovc82391e2015-03-17 15:46:36 +02007def parse_config(file_name):
8 with open(file_name) as f:
9 cfg = yaml.load(f.read())
10
11 return cfg
12
13
gstepanov5f936df2015-03-18 19:15:59 +020014parser = argparse.ArgumentParser(description="config file name")
15parser.add_argument("-p", "--path")
gstepanovb3c78962015-03-20 15:47:58 +020016parser.add_argument("-b", "--basedir")
17parser.add_argument("-t", "--testpath")
18parser.add_argument("-d", "--database")
19parser.add_argument("-c", "--chartpath")
gstepanov5f936df2015-03-18 19:15:59 +020020
21config = parser.parse_args(sys.argv[1:])
22path = "config.yaml"
23
24if not config.path is None:
25 path = config.path
26
27cfg_dict = parse_config(os.path.join(os.path.dirname(__file__), path))
gstepanovc82391e2015-03-17 15:46:36 +020028basedir = cfg_dict['paths']['basedir']
29TEST_PATH = cfg_dict['paths']['TEST_PATH']
30SQLALCHEMY_MIGRATE_REPO = cfg_dict['paths']['SQLALCHEMY_MIGRATE_REPO']
31DATABASE_URI = cfg_dict['paths']['DATABASE_URI']
gstepanov5f936df2015-03-18 19:15:59 +020032CHARTS_IMG_PATH = cfg_dict['paths']['CHARTS_IMG_PATH']
33
gstepanovb3c78962015-03-20 15:47:58 +020034if not config.basedir is None:
35 basedir = config.basedir
36
37if not config.testpath is None:
38 TEST_PATH = config.testpath
39
40if not config.database is None:
41 DATABASE_URI = config.database
42
43if not config.chartpath is None:
44 CHARTS_IMG_PATH = config.chartpath
45
gstepanov5f936df2015-03-18 19:15:59 +020046