]>
Softwares of Agnibho - ddstorm.git/blob - conf.py
5 # Copyright (c) 2015 Agnibho Mondal
8 # This file is part of DDStorm.
10 # DDStorm is free software: you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License as published by
12 # the Free Software Foundation, either version 3 of the License, or
13 # (at your option) any later version.
15 # DDStorm is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU General Public License for more details.
20 # You should have received a copy of the GNU General Public License
21 # along with DDStorm. If not, see <http://www.gnu.org/licenses/>.
25 logging
.basicConfig(filename
=LOG_FILE
)
29 def __init__(self
, filename
=CONF_FILE
):
30 self
.filename
=filename
35 self
.conf
["library_path"]="./library/"
36 self
.conf
["custom_path"]="./custom/"
37 self
.conf
["index_path"]="./index/"
38 self
.conf
["alias_path"]="./alias/"
39 self
.conf
["module_path"]="./modules/"
40 self
.conf
["splash_screen"]="yes"
41 self
.conf
["clean_log"]="no"
42 self
.conf
["status_message"]="on"
45 if(os
.path
.isfile(self
.filename
)):
46 with
open(self
.filename
) as f
:
48 line
="".join(line
.split())
49 if(line
.startswith("#")):
51 elif(line
.startswith("library_path=")):
52 self
.conf
["library_path"]=line
[13:]
53 if(os
.path
.isdir(self
.conf
["library_path"])):
54 if(not self
.conf
["library_path"].endswith("/")):
55 self
.conf
["library_path"]+="/"
56 elif(line
.startswith("custom_path=")):
57 self
.conf
["custom_path"]=line
[12:]
58 if(os
.path
.isdir(self
.conf
["custom_path"])):
59 if(not self
.conf
["custom_path"].endswith("/")):
60 self
.conf
["custom_path"]+="/"
61 elif(line
.startswith("index_path=")):
62 self
.conf
["index_path"]=line
[11:]
63 if(os
.path
.isdir(self
.conf
["index_path"])):
64 if(not self
.conf
["index_path"].endswith("/")):
65 self
.conf
["index_path"]+="/"
66 elif(line
.startswith("alias_path=")):
67 self
.conf
["alias_path"]=line
[11:]
68 if(os
.path
.isdir(self
.conf
["alias_path"])):
69 if(not self
.conf
["alias_path"].endswith("/")):
70 self
.conf
["alias_path"]+="/"
71 elif(line
.startswith("module_path=")):
72 self
.conf
["module_path"]=line
[12:]
73 if(os
.path
.isdir(self
.conf
["module_path"])):
74 if(not self
.conf
["module_path"].endswith("/")):
75 self
.conf
["module_path"]+="/"
76 elif(line
.startswith("splash_screen=")):
77 self
.conf
["splash_screen"]=line
[14:]
78 elif(line
.startswith("clean_log=")):
79 self
.conf
["clean_log"]=line
[10:]
80 elif(line
.startswith("status_message=")):
81 self
.conf
["status_message"]=line
[15:]
83 logging
.warning("Unrecognized configuration: "+line
)
85 def get(self
, key
=False):
90 def set(self
, key
, value
):
94 with
open(CONF_FILE
, "w") as f
:
96 print(k
+"="+self
.conf
[k
], file=f
)
98 if(__name__
=="__main__"):