OSDN Git Service

add dist
[rec10/rec10-git.git] / dist / trunk / rec10 / configreader.py
diff --git a/dist/trunk/rec10/configreader.py b/dist/trunk/rec10/configreader.py
new file mode 100755 (executable)
index 0000000..cf1eee5
--- /dev/null
@@ -0,0 +1,30 @@
+#!/usr/bin/python\r
+# coding: UTF-8\r
+# Rec10 TS Recording Tools\r
+# Copyright (C) 2009-2011 Yukikaze\r
+import ConfigParser\r
+import os\r
+import os.path\r
+mypath = str(os.path.dirname(os.path.abspath(__file__)))\r
+confp = ConfigParser.SafeConfigParser()\r
+Conf = 'rec10.conf'\r
+confpath=""\r
+if os.path.exists(os.path.join(mypath,Conf)):\r
+    confpath=os.path.join(mypath,Conf)\r
+elif os.path.exists(os.path.join("/etc","rec10.conf")):\r
+    confpath=os.path.join("/etc","rec10.conf")\r
+elif os.path.exists(os.path.join("/etc/rec10","rec10.conf")):\r
+    confpath=os.path.join("/etc/rec10","rec10.conf")\r
+confp.read(confpath)\r
+def getConfPath(string):\r
+    global confp\r
+    return confp.get('path', string)\r
+def getConfDB(string):\r
+    global confp\r
+    return confp.get('db', string)\r
+def getConfEnv(string):\r
+    global confp\r
+    return confp.get('env', string)\r
+def getConfLog(string):\r
+    global confp\r
+    return confp.get('log', string)\r