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

Method prepareRepAmountData

graphs/data/fitRemoteReps/cache.py:96–125  ·  view source on GitHub ↗
(self, src, ancReload, maxTime)

Source from the content-addressed store, hash-verified

94 finalRpsCache[time] = timeRpsData
95
96 def prepareRepAmountData(self, src, ancReload, maxTime):
97 # Time is none means that time parameter has to be ignored,
98 # we do not need cache for that
99 if maxTime is None:
100 return
101 self._generateInternalForm(src=src, ancReload=ancReload, maxTime=maxTime)
102 fitCache = self._data[src.item.ID][ancReload]
103 # Final cache has been generated already, don't do anything
104 if 'finalRepAmount' in fitCache:
105 return
106 intCache = fitCache['internalRepAmount']
107 changesByTime = {}
108 for key, remAmountMap in intCache.items():
109 for time in remAmountMap:
110 changesByTime.setdefault(time, []).append(key)
111 # Here we convert cache to following format:
112 # {time: {key: hp repaired by key at this time}}
113 finalCache = fitCache['finalRepAmount'] = {}
114 timeRepAmountData = {}
115 for time in sorted(changesByTime):
116 timeRepAmountData = copy(timeRepAmountData)
117 for key in changesByTime[time]:
118 keyRepAmount = intCache[key][time]
119 if key in timeRepAmountData:
120 timeRepAmountData[key] = timeRepAmountData[key] + keyRepAmount
121 else:
122 timeRepAmountData[key] = keyRepAmount
123 finalCache[time] = timeRepAmountData
124 # We do not need internal cache once we have final
125 del fitCache['internalRepAmount']
126
127 # Private stuff
128 def _generateInternalForm(self, src, ancReload, maxTime):

Callers 1

_prepareTimeCacheMethod · 0.80

Calls 3

_generateInternalFormMethod · 0.95
itemsMethod · 0.80
appendMethod · 0.45

Tested by

no test coverage detected