]>
Softwares of Agnibho - ddstorm.git/blob - alias.py
3 ''' This module handles the aliases of the symptoms. '''
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/>.
26 from fnmatch
import fnmatch
32 ''' Provides the class to handle symptom aliases '''
34 def __init__(self
, conf
=False):
36 Initiates the alias object
37 Accepts a Conf object as parameter
47 ''' Compile the plaintext index files to a program usable format '''
48 # Loop over the alias files
49 for path
, subdirs
, files
in os
.walk(self
.conf
.get("alias_path")):
51 if(fnmatch(name
, "*.txt")):
52 # Open the *.txt files
53 with
open(self
.conf
.get("alias_path")+name
, "r") as f
:
55 # Ignore lines starting with #
56 line
=line
.rstrip().split("#")[0]
61 # Split words separated by ; and add to the terms
62 for i
in line
.split(";"):
64 terms
.append(i
.strip())
65 # If alias present, add terms to the data
67 self
.data
[terms
[-1]]=terms
[0]
75 Return the alias of the queried symptom
81 String containing the alias of the term
83 if(term
in self
.data
):
84 return self
.data
[term
]
89 ''' Print the alias of the command line argument '''
92 print(a
.get(sys
.argv
[1]))
94 if(__name__
=="__main__"):