gns-deb-diff

automate the documentation of the differences between gNewSense and Debian.
git clone git://git.ricketyspace.net/gns-deb-diff.git
Log | Files | Refs

commit ba6981811e863e9929db87533a88b8ead52f9369
parent 61a47f6da59efc6369edb6c8562f663bc4c0333d
Author: rsiddharth <s@ricketyspace.net>
Date:   Sun, 13 Nov 2016 01:14:09 +0000

Update `config_dir` function.

Now creates the config directory if it is not already created.

* gd_diff.py (config_dir): Update function.
* tests/test_gd_diff.py (test_config_dir): Update test.
(test_configured_p_yes): Update test.

Diffstat:
gd_diff.py | 12+++++++++++-
tests/test_gd_diff.py | 2+-
2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/gd_diff.py b/gd_diff.py @@ -212,7 +212,17 @@ def slurp_fields_from_readme(content): def config_dir(): - return os.path.join(os.getenv('HOME'), '.config', 'gns-deb-diff') + """Return the gns-deb-diff config directory. + + As a side effect, the directory is created if it does not exist. + + """ + cd = os.path.join(os.getenv('HOME'), '.config', 'gns-deb-diff') + + if not os.path.isdir(cd): + os.makedirs(cd) + + return cd def config_file(): diff --git a/tests/test_gd_diff.py b/tests/test_gd_diff.py @@ -234,6 +234,7 @@ class TestGdDiff(object): c_dir = config_dir() assert_equal(c_dir, os.path.join(self.test_home, '.config', 'gns-deb-diff')) + assert_equal(os.path.isdir(c_dir), True) def test_config_file(self): @@ -263,7 +264,6 @@ class TestGdDiff(object): c_path = config_dir() c_file = config_file() - os.makedirs(c_path) open(c_file, 'w').close() configured = configured_p()