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

Method Do

gui/fitCommands/calc/module/localRemove.py:26–54  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

24 self.savedTail = None
25
26 def Do(self):
27 pyfalog.debug('Doing removal of local modules from positions {} on fit {}'.format(self.positions, self.fitID))
28 sFit = Fit.getInstance()
29 fit = sFit.getFit(self.fitID)
30
31 self.savedSubInfos = {}
32 self.savedModInfos = {}
33 for position in self.positions:
34 mod = fit.modules[position]
35 if not mod.isEmpty:
36 if mod.slot == FittingSlot.SUBSYSTEM:
37 self.savedSubInfos[position] = ModuleInfo.fromModule(mod)
38 else:
39 self.savedModInfos[position] = ModuleInfo.fromModule(mod)
40 fit.modules.free(position)
41
42 if len(self.savedSubInfos) == 0 and len(self.savedModInfos) == 0:
43 return False
44
45 if self.clearTail:
46 self.savedTail = fit.clearTail()
47
48 if self.recalc:
49 # Need to flush because checkStates sometimes relies on module->fit
50 # relationship via .owner attribute, which is handled by SQLAlchemy
51 eos.db.flush()
52 sFit.recalc(fit)
53 self.savedStateCheckChanges = sFit.checkStates(fit, None)
54 return True
55
56 def Undo(self):
57 pyfalog.debug('Undoing removal of local modules {} on fit {}'.format(self.savedModInfos, self.fitID))

Callers 4

getT2MwdSpeedMethod · 0.95
UndoMethod · 0.95
UndoMethod · 0.95
UndoMethod · 0.95

Calls 8

getFitMethod · 0.80
fromModuleMethod · 0.80
freeMethod · 0.80
clearTailMethod · 0.80
flushMethod · 0.80
recalcMethod · 0.80
checkStatesMethod · 0.80
getInstanceMethod · 0.45

Tested by

no test coverage detected