]>
Softwares of Agnibho - ddstorm.git/blob - ddstorm.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/>.
24 from compile import Compile
26 from index
import Index
30 def __init__(self
, comp
=False, conf
=False):
36 self
.compiler
=Compile(conf
)
37 self
.index
=Index(conf
)
39 def dd(self
, symptoms
):
42 diff1
=self
._getDiff
(symptoms
.pop(0))
44 diff2
=self
._getDiff
(s
)
46 if(len(diff1
)>len(diff2
)):
47 diff2
+=[""]*(len(diff1
)-len(diff2
))
48 elif(len(diff2
)>len(diff1
)):
49 diff1
+=[""]*(len(diff2
)-len(diff1
))
50 for (s1
, s2
) in zip(diff1
, diff2
):
51 if((s1
not in temp
) and (len(s1
)>0)):
55 us
=self
.index
.upstream(s1
)
59 if((s2
not in temp
) and (len(s2
)>0)):
63 us
=self
.index
.upstream(s2
)
70 def _getDiff(self
, symptom
):
72 symptom
=symptom
.lower().replace("_"," ").replace("-", " ")
73 if(os
.path
.isfile(self
.conf
.get("module_path")+symptom
+".module")):
74 with
open(self
.conf
.get("module_path")+symptom
+".module", "r") as mf
:
76 diff
.append(line
.strip())
81 for n
in os
.listdir(self
.conf
.get("module_path")):
82 symp
.append(os
.path
.splitext(os
.path
.basename(n
))[0].capitalize())
88 for d
in s
.dd(sys
.argv
[1:]):
91 for s
in s
.symptoms():
94 if(__name__
=="__main__"):