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

Function importESI

service/port/esi.py:163–237  ·  view source on GitHub ↗
(string)

Source from the content-addressed store, hash-verified

161
162
163def importESI(string):
164
165 sMkt = Market.getInstance()
166 fitobj = Fit()
167 refobj = json.loads(string)
168 items = refobj['items']
169 # "<" and ">" is replace to "&lt;", "&gt;" by EVE client
170 fitobj.name = refobj['name']
171 # 2017/03/29: read description
172 fitobj.notes = refobj['description']
173
174 try:
175 ship = refobj['ship_type_id']
176 try:
177 fitobj.ship = Ship(sMkt.getItem(ship))
178 except ValueError:
179 fitobj.ship = Citadel(sMkt.getItem(ship))
180 except (KeyboardInterrupt, SystemExit):
181 raise
182 except:
183 pyfalog.warning("Caught exception in importESI")
184 return None
185
186 items.sort(key=lambda k: k['flag'])
187
188 moduleList = []
189 for module in items:
190 try:
191 item = sMkt.getItem(module['type_id'], eager="group.category")
192 if not item.published:
193 continue
194 if module['flag'] == INV_FLAG_DRONEBAY:
195 d = Drone(item)
196 d.amount = module['quantity']
197 fitobj.drones.append(d)
198 elif module['flag'] == INV_FLAG_CARGOBAY:
199 c = Cargo(item)
200 c.amount = module['quantity']
201 fitobj.cargo.append(c)
202 elif module['flag'] == INV_FLAG_FIGHTER:
203 fighter = Fighter(item)
204 fitobj.fighters.append(fighter)
205 else:
206 try:
207 m = Module(item)
208 # When item can't be added to any slot (unknown item or just charge), ignore it
209 except ValueError:
210 pyfalog.debug("Item can't be added to any slot (unknown item or just charge)")
211 continue
212 # Add subsystems before modules to make sure T3 cruisers have subsystems installed
213 if item.category.name == "Subsystem":
214 if m.fits(fitobj):
215 fitobj.modules.append(m)
216 else:
217 if m.isValidState(FittingModuleState.ACTIVE):
218 m.state = activeStateLimit(m.item)
219
220 moduleList.append(m)

Callers 1

importESIMethod · 0.90

Calls 15

fitsMethod · 0.95
isValidStateMethod · 0.95
FitClass · 0.90
ShipClass · 0.90
CitadelClass · 0.90
DroneClass · 0.90
CargoClass · 0.90
FighterClass · 0.90
ModuleClass · 0.90
activeStateLimitFunction · 0.90
getItemMethod · 0.80
recalcMethod · 0.80

Tested by

no test coverage detected