1
0
Fork 0
mirror of synced 2024-12-22 06:01:07 -05:00

Merge branch 'joshblum/config-logging'

This commit is contained in:
Anish Athalye 2015-04-24 18:34:51 -04:00
commit 3a649c1112
2 changed files with 8 additions and 2 deletions

View file

@ -1,4 +1,5 @@
import yaml
from .util import string
class ConfigReader(object):
def __init__(self, config_file_path):
@ -9,8 +10,9 @@ class ConfigReader(object):
with open(config_file_path) as fin:
data = yaml.load(fin)
return data
except Exception:
raise ReadingError('Could not read config file')
except Exception as e:
msg = string.indent_lines(str(e))
raise ReadingError('Could not read config file:\n%s' % msg)
def get_config(self):
return self._config

4
dotbot/util/string.py Normal file
View 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)))