summaryrefslogtreecommitdiff
path: root/dotbot
diff options
context:
space:
mode:
authorAnish Athalye <me@anishathalye.com>2016-01-13 11:29:12 -0500
committerAnish Athalye <me@anishathalye.com>2016-01-13 11:29:12 -0500
commitc48d16cbce1dc082bc0b2f8ab3f34e7c0829cf89 (patch)
tree015da0cf2c332143e3c5f6734d1baabbefb23bb4 /dotbot
parent9250bef422703ff9f676da84f6f5c28c61ad3fc4 (diff)
Use standard library JSON parser for JSON files
This patch reverts the changes to the README made in 57265f78b4e4f6ca67393f55b2b08f6f45a02ff1 and makes it so that Dotbot supports JSON files with tab characters.
Diffstat (limited to 'dotbot')
-rw-r--r--dotbot/config.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/dotbot/config.py b/dotbot/config.py
index 9ecf9ac..a9aafa0 100644
--- a/dotbot/config.py
+++ b/dotbot/config.py
@@ -1,4 +1,5 @@
import yaml
+import json
from .util import string
class ConfigReader(object):
@@ -8,7 +9,16 @@ class ConfigReader(object):
def _read(self, config_file_path):
try:
with open(config_file_path) as fin:
- data = yaml.safe_load(fin)
+ try:
+ 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))