]> khamidou — GitHub mirrors - cagibi.git/commitdiff
refactored code
authorkarim hamidou <khamidou@gmail.com>
Fri, 10 Aug 2012 08:54:05 +0000 (10:54 +0200)
committerkarim hamidou <khamidou@gmail.com>
Fri, 10 Aug 2012 08:54:05 +0000 (10:54 +0200)
cagibi/config.py

index d8eeefd5d995c82ce4faeab782d9480ed7ba8713..6612b9615ffcf030af702786a8ba1f09662492d0 100644 (file)
@@ -1,5 +1,7 @@
 # -*- coding: utf-8 -*-
+import sys
 import json
+import os
 
 def load_config(filename="config.json"):
     """load a configuration file in json"""
@@ -8,3 +10,13 @@ def load_config(filename="config.json"):
 def save_config(config, filename="config.json"):
     """save a configuration file"""
     json.dump(config, open(filename, 'w'))
+
+def get_config_path():
+    if os.name != "posix":
+        from win32com.shell import shellcon, shell
+        confpath = "{}\\cagibi\\cagibi.conf".format(shell.SHGetFolderPath(0, shellcon.CSIDL_APPDATA, 0, 0))
+    else:
+        confpath = "{}/.cagibi/cagibi.conf".format(os.path.expanduser("~"))
+
+    return confpath
+