Merge branch 'joshblum/config-logging'
This commit is contained in:
commit
3a649c1112
|
@ -1,4 +1,5 @@
|
||||||
import yaml
|
import yaml
|
||||||
|
from .util import string
|
||||||
|
|
||||||
class ConfigReader(object):
|
class ConfigReader(object):
|
||||||
def __init__(self, config_file_path):
|
def __init__(self, config_file_path):
|
||||||
|
@ -9,8 +10,9 @@ class ConfigReader(object):
|
||||||
with open(config_file_path) as fin:
|
with open(config_file_path) as fin:
|
||||||
data = yaml.load(fin)
|
data = yaml.load(fin)
|
||||||
return data
|
return data
|
||||||
except Exception:
|
except Exception as e:
|
||||||
raise ReadingError('Could not read config file')
|
msg = string.indent_lines(str(e))
|
||||||
|
raise ReadingError('Could not read config file:\n%s' % msg)
|
||||||
|
|
||||||
def get_config(self):
|
def get_config(self):
|
||||||
return self._config
|
return self._config
|
||||||
|
|
4
dotbot/util/string.py
Normal file
4
dotbot/util/string.py
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
def indent_lines(string, amount=2, delimiter='\n'):
|
||||||
|
whitespace = ' ' * amount
|
||||||
|
sep = '%s%s' % (delimiter, whitespace)
|
||||||
|
return '%s%s' % (whitespace, sep.join(string.split(delimiter)))
|
Loading…
Reference in a new issue