gstepanov | 725cc30 | 2015-02-09 15:08:06 +0200 | [diff] [blame] | 1 | import os |
koder aka kdanilov | e06762a | 2015-03-22 23:32:09 +0200 | [diff] [blame] | 2 | # import sys |
| 3 | import yaml |
| 4 | # import argparse |
gstepanov | 725cc30 | 2015-02-09 15:08:06 +0200 | [diff] [blame] | 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 | |
koder aka kdanilov | e06762a | 2015-03-22 23:32:09 +0200 | [diff] [blame] | 14 | # WTX??? |
| 15 | # parser = argparse.ArgumentParser(description="config file name") |
| 16 | # parser.add_argument("-p", "--path") |
| 17 | # parser.add_argument("-b", "--basedir") |
| 18 | # parser.add_argument("-t", "--testpath") |
| 19 | # parser.add_argument("-d", "--database") |
| 20 | # parser.add_argument("-c", "--chartpath") |
gstepanov | 5f936df | 2015-03-18 19:15:59 +0200 | [diff] [blame] | 21 | |
koder aka kdanilov | e06762a | 2015-03-22 23:32:09 +0200 | [diff] [blame] | 22 | # config = parser.parse_args(sys.argv[1:]) |
gstepanov | 5f936df | 2015-03-18 19:15:59 +0200 | [diff] [blame] | 23 | path = "config.yaml" |
| 24 | |
koder aka kdanilov | e06762a | 2015-03-22 23:32:09 +0200 | [diff] [blame] | 25 | # if config.path is not None: |
| 26 | # path = config.path |
gstepanov | 5f936df | 2015-03-18 19:15:59 +0200 | [diff] [blame] | 27 | |
| 28 | cfg_dict = parse_config(os.path.join(os.path.dirname(__file__), path)) |
gstepanov | c82391e | 2015-03-17 15:46:36 +0200 | [diff] [blame] | 29 | basedir = cfg_dict['paths']['basedir'] |
| 30 | TEST_PATH = cfg_dict['paths']['TEST_PATH'] |
| 31 | SQLALCHEMY_MIGRATE_REPO = cfg_dict['paths']['SQLALCHEMY_MIGRATE_REPO'] |
| 32 | DATABASE_URI = cfg_dict['paths']['DATABASE_URI'] |
gstepanov | 5f936df | 2015-03-18 19:15:59 +0200 | [diff] [blame] | 33 | CHARTS_IMG_PATH = cfg_dict['paths']['CHARTS_IMG_PATH'] |
| 34 | |
koder aka kdanilov | e06762a | 2015-03-22 23:32:09 +0200 | [diff] [blame] | 35 | # if config.basedir is not None: |
| 36 | # basedir = config.basedir |
gstepanov | b3c7896 | 2015-03-20 15:47:58 +0200 | [diff] [blame] | 37 | |
koder aka kdanilov | e06762a | 2015-03-22 23:32:09 +0200 | [diff] [blame] | 38 | # if config.testpath is not None: |
| 39 | # TEST_PATH = config.testpath |
gstepanov | b3c7896 | 2015-03-20 15:47:58 +0200 | [diff] [blame] | 40 | |
koder aka kdanilov | e06762a | 2015-03-22 23:32:09 +0200 | [diff] [blame] | 41 | # if config.database is not None: |
| 42 | # DATABASE_URI = config.database |
gstepanov | b3c7896 | 2015-03-20 15:47:58 +0200 | [diff] [blame] | 43 | |
koder aka kdanilov | e06762a | 2015-03-22 23:32:09 +0200 | [diff] [blame] | 44 | # if config.chartpath is not None: |
| 45 | # CHARTS_IMG_PATH = config.chartpath |