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

Function importXml

service/port/xml.py:157–280  ·  view source on GitHub ↗
(text, progress)

Source from the content-addressed store, hash-verified

155
156
157def importXml(text, progress):
158 from .port import Port
159 sMkt = Market.getInstance()
160 doc = xml.dom.minidom.parseString(text)
161 # NOTE:
162 # When L_MARK is included at this point,
163 # Decided to be localized data
164 b_localized = L_MARK in text
165 fittings = doc.getElementsByTagName("fittings").item(0)
166 fittings = fittings.getElementsByTagName("fitting")
167 fit_list = []
168 failed = 0
169
170 for fitting in fittings:
171 if progress and progress.userCancelled:
172 return []
173
174 try:
175 fitobj = _resolve_ship(fitting, sMkt, b_localized)
176 except (KeyboardInterrupt, SystemExit):
177 raise
178 except:
179 failed += 1
180 continue
181
182 # -- 170327 Ignored description --
183 # read description from exported xml. (EVE client, EFT)
184 description = fitting.getElementsByTagName("description").item(0).getAttribute("value")
185 if description is None:
186 description = ""
187 elif len(description):
188 # convert <br> to "\n" and remove html tags.
189 if Port.is_tag_replace():
190 description = replace_ltgt(
191 sequential_rep(description, r"<(br|BR)>", "\n", r"<[^<>]+>", "")
192 )
193 fitobj.notes = description
194
195 hardwares = fitting.getElementsByTagName("hardware")
196 moduleList = []
197 for hardware in hardwares:
198 try:
199 item, mutaItem, mutaAttrs = _resolve_module(hardware, sMkt, b_localized)
200 if not item or not item.published:
201 continue
202
203 if item.category.name == "Drone":
204 d = None
205 if mutaItem:
206 mutaplasmid = getDynamicItem(mutaItem.ID)
207 if mutaplasmid:
208 try:
209 d = Drone(mutaplasmid.resultingItem, item, mutaplasmid)
210 except ValueError:
211 pass
212 else:
213 for attrID, mutator in d.mutators.items():
214 if attrID in mutaAttrs:

Callers 1

importXmlMethod · 0.90

Calls 15

fitsMethod · 0.95
isValidStateMethod · 0.95
replace_ltgtFunction · 0.90
sequential_repFunction · 0.90
getDynamicItemFunction · 0.90
DroneClass · 0.90
FighterClass · 0.90
CargoClass · 0.90
ModuleClass · 0.90
activeStateLimitFunction · 0.90
_resolve_shipFunction · 0.85
_resolve_moduleFunction · 0.85

Tested by

no test coverage detected