gstepanov | 5f936df | 2015-03-18 19:15:59 +0200 | [diff] [blame^] | 1 | import argparse |
| 2 | import sys |
gstepanov | c82391e | 2015-03-17 15:46:36 +0200 | [diff] [blame] | 3 | import yaml |
gstepanov | 725cc30 | 2015-02-09 15:08:06 +0200 | [diff] [blame] | 4 | import os |
| 5 | |
stgleb | 75c7041 | 2015-02-17 02:52:00 +0200 | [diff] [blame] | 6 | |
gstepanov | c82391e | 2015-03-17 15:46:36 +0200 | [diff] [blame] | 7 | def parse_config(file_name): |
| 8 | with open(file_name) as f: |
| 9 | cfg = yaml.load(f.read()) |
| 10 | |
| 11 | return cfg |
| 12 | |
| 13 | |
gstepanov | 5f936df | 2015-03-18 19:15:59 +0200 | [diff] [blame^] | 14 | parser = argparse.ArgumentParser(description="config file name") |
| 15 | parser.add_argument("-p", "--path") |
| 16 | |
| 17 | config = parser.parse_args(sys.argv[1:]) |
| 18 | path = "config.yaml" |
| 19 | |
| 20 | if not config.path is None: |
| 21 | path = config.path |
| 22 | |
| 23 | cfg_dict = parse_config(os.path.join(os.path.dirname(__file__), path)) |
gstepanov | c82391e | 2015-03-17 15:46:36 +0200 | [diff] [blame] | 24 | basedir = cfg_dict['paths']['basedir'] |
| 25 | TEST_PATH = cfg_dict['paths']['TEST_PATH'] |
| 26 | SQLALCHEMY_MIGRATE_REPO = cfg_dict['paths']['SQLALCHEMY_MIGRATE_REPO'] |
| 27 | DATABASE_URI = cfg_dict['paths']['DATABASE_URI'] |
gstepanov | 5f936df | 2015-03-18 19:15:59 +0200 | [diff] [blame^] | 28 | CHARTS_IMG_PATH = cfg_dict['paths']['CHARTS_IMG_PATH'] |
| 29 | |
| 30 | |