diff --git a/dotbot/config.py b/dotbot/config.py index a9aafa0..39ab60b 100644 --- a/dotbot/config.py +++ b/dotbot/config.py @@ -1,5 +1,6 @@ import yaml import json +import os.path from .util import string class ConfigReader(object): @@ -8,17 +9,13 @@ class ConfigReader(object): def _read(self, config_file_path): try: + _, ext = os.path.splitext(config_file_path) with open(config_file_path) as fin: - try: + print ext + if ext == '.json': + data = json.load(fin) + else: data = yaml.safe_load(fin) - except Exception as e: - # try falling back to JSON, but return original exception - # if that fails too - try: - fin.seek(0) - data = json.load(fin) - except Exception: - raise e return data except Exception as e: msg = string.indent_lines(str(e))