-
Notifications
You must be signed in to change notification settings - Fork 8
/
config.py
39 lines (30 loc) · 981 Bytes
/
config.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
36
37
38
39
# -*- coding: utf-8 -*-
import json
import os.path
class ConfigReader(object):
"""
Snowblock configuration file reader.
"""
def __init__(self, config_file_path):
self._config = self._read(config_file_path)
def _read(self, config_file_path):
"""
Reads the specified configuration file.
:param config_file_path: The path to the configuration file to read
:return: The read configuration data
"""
try:
_, ext = os.path.splitext(config_file_path)
with open(config_file_path) as fin:
data = json.load(fin)
return data
except Exception as e:
raise ReadingError('Could not read config file:\n{}'.format(e))
def get_config(self):
"""
Gets the snowblock configuration data.
:return: The read snowblock configuration data
"""
return self._config
class ReadingError(Exception):
pass