Statistics
| Revision:

svn-gvsig-desktop / branches / v2_0_0_prep / build / buildman / bin / bmbase / IPlugIn.py @ 27363

History | View | Annotate | Download (1.29 KB)

1
from xml.dom import minidom
2

    
3
'''
4
        Defines a interface for plugins
5
'''
6
class IPlugIn:
7
        def __init__(self):
8
                self._errorMessages = []
9
                self._error = False
10
                self._id = ""
11
                self._goals = dict()
12
                self._arguments = None
13
                self._execute = False
14

    
15
        def initArguments(self,arguments):
16
                self._arguments = arguments
17

    
18
        def init(self):
19
                pass
20

    
21
        def initFromXML(self,node):
22
                pass
23
        
24
        def execute(self):
25
                pass
26
        
27
        def loadXMLFile(self,xmlfile):
28
                xmldoc=minidom.parse(xmlfile)
29
                node = xmldoc.firstChild
30
                self.initFromXML(node)
31
        
32
        def getExecute(self):
33
                return self._execute
34
        
35
        def setExecute(self,value):
36
                self._execute = value
37
                
38
        def run(self):
39
                if self._execute:
40
                        self.execute()
41

    
42
        
43
        def reportError(self,s):
44
                self._errorMessages.append(str(self.__class__)+":"+s)
45
                self._error = True
46

    
47
        def error(self):
48
                return self._error
49

    
50
        def getErrorMessages(self):
51
                return self._errorMessages
52

    
53
        def setId(self,id):
54
                self._id = id
55

    
56
        def getId(self):
57
                return self._id
58

    
59
        def addGoal(self,goal,description):
60
                self._goals[goal] = []
61
                self._arguments.getApplicationUsage().addCommandLineGoal(goal,description)
62
        
63
        def addGoalOption(self,goal,option,description):
64
                self._goals[goal].append(option)
65
                self._arguments.getApplicationUsage().addCommandLineGoalOption(goal,option,description)
66

    
67
        def getGoals(self):
68
                return self._goals
69