diff options
author | rsiddharth <s@ricketyspace.net> | 2016-11-13 16:42:54 +0000 |
---|---|---|
committer | rsiddharth <s@ricketyspace.net> | 2016-11-13 16:42:54 +0000 |
commit | 0b80b898c84b8747fe8b8ac7b485b06f7cd1e22e (patch) | |
tree | bb50974f2734c23b7ed7e7d8a558a11266659a66 /gd_diff.py | |
parent | 92b8a39ca5d48dad73c646439529e9f84a76fc78 (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.py | 14 |
1 files changed, 14 insertions, 0 deletions
@@ -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. |