Cosmetic change in PSKManagement.py
authorEdouard Tisserant
Tue, 27 Nov 2018 10:54:13 +0100
changeset 2461 9624575a9cac
parent 2460 89abeece2c71
child 2462 ed6b0e905fcb
Cosmetic change in PSKManagement.py
PSKManagement.py
--- a/PSKManagement.py	Mon Nov 26 15:12:18 2018 +0100
+++ b/PSKManagement.py	Tue Nov 27 10:54:13 2018 +0100
@@ -20,6 +20,12 @@
 def _mgtpath(project_path):
     return os.path.join(_pskpath(project_path), 'management.json')
 
+def _ensurePSKdir(project_path):
+    pskpath = _pskpath(project_path)
+    if not os.path.exists(pskpath):
+        os.mkdir(pskpath)
+    return pskpath
+
 def _default(ID):
     return [ID,
             '', # default description
@@ -62,15 +68,12 @@
     os.remove(secret_path)
 
 def SaveData(project_path, data):
-    pskpath = _pskpath(project_path)
-    if not os.path.isdir(pskpath):
-        os.mkdir(pskpath)
+    _ensurePSKdir(project_path)
     with open(_mgtpath(project_path), 'w') as f:
         f.write(json.dumps(data))
 
-
 def UpdateID(project_path, ID, secret, URI):
-    pskpath = _pskpath(project_path)
+    pskpath = _ensurePSKdir(project_path)
     if not os.path.exists(pskpath):
         os.mkdir(pskpath)