summaryrefslogtreecommitdiffstats
path: root/gd_diff.py
diff options
context:
space:
mode:
authorrsiddharth <s@ricketyspace.net>2016-11-13 16:42:54 +0000
committerrsiddharth <s@ricketyspace.net>2016-11-13 16:42:54 +0000
commit0b80b898c84b8747fe8b8ac7b485b06f7cd1e22e (patch)
treebb50974f2734c23b7ed7e7d8a558a11266659a66 /gd_diff.py
parent92b8a39ca5d48dad73c646439529e9f84a76fc78 (diff)
Add `read_config_file` function.
* gd_diff.py (read_config_file): New function. * tests/test_gd_diff.py (test_read_config_file_fail) (test_read_config_file_success): Tests for read_config_file.
Diffstat (limited to 'gd_diff.py')
-rw-r--r--gd_diff.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/gd_diff.py b/gd_diff.py
index 5f069d1..220f832 100644
--- a/gd_diff.py
+++ b/gd_diff.py
@@ -6,6 +6,7 @@
# gns-deb-diff is under the Public Domain. See
# <https://creativecommons.org/publicdomain/zero/1.0>
+import json
import os
import re
import shlex
@@ -229,6 +230,19 @@ def config_file():
return os.path.join(config_dir(), 'config')
+def read_config_file():
+ """Return config as a Python Object; False when config does not \
+ exist.
+
+ """
+ cf = config_file()
+
+ if not os.path.isfile(cf):
+ return False
+
+ return json.load(open(cf, 'r'))
+
+
def pkgs_dir():
"""Return the `pkgs` directory.