Skip to content

Commit

Permalink
Merge branch 'feature/ghi-#1-configuration-reader' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
arcticicestudio committed Jan 7, 2017
2 parents 37bbe62 + a34b1a5 commit bc9468d
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions snowsaw/config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
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

0 comments on commit bc9468d

Please sign in to comment.