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

Function processImportInfo

service/port/dna.py:82–157  ·  view source on GitHub ↗
(info, fitName, amountSeparator)

Source from the content-addressed store, hash-verified

80 return processImportInfo(info, fitName, "*")
81
82def processImportInfo(info, fitName, amountSeparator):
83 sMkt = Market.getInstance()
84 f = Fit()
85 try:
86 try:
87 f.ship = Ship(sMkt.getItem(int(info[0])))
88 except ValueError:
89 f.ship = Citadel(sMkt.getItem(int(info[0])))
90 if fitName is None:
91 f.name = "{0} - DNA Imported".format(f.ship.item.name)
92 else:
93 f.name = fitName
94 except UnicodeEncodeError:
95 def logtransform(s_):
96 if len(s_) > 10:
97 return s_[:10] + "..."
98 return s_
99
100 pyfalog.exception("Couldn't import ship data {0}", [logtransform(s) for s in info])
101 return None
102
103 moduleList = []
104 for itemInfo in info[1:]:
105 if itemInfo:
106 if amountSeparator in itemInfo:
107 itemID, amount = itemInfo.split(amountSeparator)
108 else:
109 itemID = itemInfo
110 amount = 1
111 item = sMkt.getItem(int(itemID), eager="group.category")
112
113 if item.category.name == "Drone":
114 d = Drone(item)
115 d.amount = int(amount)
116 f.drones.append(d)
117 elif item.category.name == "Fighter":
118 ft = Fighter(item)
119 ft.amount = int(amount) if ft.amount <= ft.fighterSquadronMaxSize else ft.fighterSquadronMaxSize
120 if ft.fits(f):
121 f.fighters.append(ft)
122 elif item.category.name == "Charge":
123 c = Cargo(item)
124 c.amount = int(amount)
125 f.cargo.append(c)
126 else:
127 for i in range(int(amount)):
128 try:
129 m = Module(item)
130 except (KeyboardInterrupt, SystemExit):
131 raise
132 except:
133 pyfalog.warning("Exception caught in importDna")
134 continue
135 # Add subsystems before modules to make sure T3 cruisers have subsystems installed
136 if item.category.name == "Subsystem":
137 if m.fits(f):
138 f.modules.append(m)
139 else:

Callers 2

importDnaFunction · 0.85
importDnaAltFunction · 0.85

Calls 15

fitsMethod · 0.95
fitsMethod · 0.95
isValidStateMethod · 0.95
FitClass · 0.90
ShipClass · 0.90
CitadelClass · 0.90
DroneClass · 0.90
FighterClass · 0.90
CargoClass · 0.90
ModuleClass · 0.90
activeStateLimitFunction · 0.90
logtransformFunction · 0.85

Tested by

no test coverage detected