MCPcopy Index your code
hub / github.com/pyfa-org/Pyfa / CalcRemoveCommandFitCommand

Class CalcRemoveCommandFitCommand

gui/fitCommands/calc/commandFit/remove.py:10–46  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8
9
10class CalcRemoveCommandFitCommand(wx.Command):
11
12 def __init__(self, fitID, commandFitID):
13 wx.Command.__init__(self, True, 'Remove Command Fit')
14 self.fitID = fitID
15 self.commandFitID = commandFitID
16 self.savedState = None
17
18 def Do(self):
19 pyfalog.debug('Doing removal of command fit {} for fit {}'.format(self.commandFitID, self.fitID))
20 sFit = Fit.getInstance()
21 fit = sFit.getFit(self.fitID)
22 commandFit = sFit.getFit(self.commandFitID)
23
24 # Can be removed by the time we're redoing it
25 if commandFit is None:
26 pyfalog.debug('Command fit is not available')
27 return False
28 commandInfo = commandFit.getCommandInfo(self.fitID)
29 if commandInfo is None:
30 pyfalog.warning('Fit command info is not available')
31 return False
32 self.savedState = commandInfo.active
33 if commandFit.ID not in fit.commandFitDict:
34 pyfalog.warning('Unable to find commanding fit in command dict')
35 return False
36 del fit.commandFitDict[commandFit.ID]
37 return True
38
39 def Undo(self):
40 pyfalog.debug('Undoing removal of command fit {} for fit {}'.format(self.commandFitID, self.fitID))
41 from .add import CalcAddCommandCommand
42 cmd = CalcAddCommandCommand(
43 fitID=self.fitID,
44 commandFitID=self.commandFitID,
45 state=self.savedState)
46 return cmd.Do()

Callers 2

DoMethod · 0.90
UndoMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected