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

Method Do

gui/fitCommands/calc/commandFit/add.py:19–49  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

17 self.state = state
18
19 def Do(self):
20 pyfalog.debug('Doing addition of command fit {} for fit {}'.format(self.commandFitID, self.fitID))
21 sFit = Fit.getInstance()
22 fit = sFit.getFit(self.fitID)
23 commandFit = sFit.getFit(self.commandFitID)
24
25 # Command fit could have been deleted if we are redoing
26 if commandFit is None:
27 pyfalog.debug('Command fit is not available')
28 return False
29 # Already commanding this ship
30 if commandFit in fit.commandFits:
31 pyfalog.debug('Command fit had been applied already')
32 return False
33 if commandFit.ID in fit.commandFitDict:
34 pyfalog.debug('Commanding fit is in command dict already')
35 return False
36 fit.commandFitDict[commandFit.ID] = commandFit
37 # This bit is required, see issue #83
38 eos.db.saveddata_session.flush()
39 eos.db.saveddata_session.refresh(commandFit)
40
41 if self.state is not None:
42 fitCommandInfo = commandFit.getCommandInfo(self.fitID)
43 if fitCommandInfo is None:
44 pyfalog.warning('Fit command info is not available')
45 self.Undo()
46 return False
47 fitCommandInfo.active = self.state
48
49 return True
50
51 def Undo(self):
52 pyfalog.debug('Undoing addition of command fit {} for fit {}'.format(self.commandFitID, self.fitID))

Callers 1

UndoMethod · 0.95

Calls 6

UndoMethod · 0.95
getFitMethod · 0.80
flushMethod · 0.80
getCommandInfoMethod · 0.80
getInstanceMethod · 0.45
refreshMethod · 0.45

Tested by

no test coverage detected