(fits, progress, callback)
| 281 | |
| 282 | |
| 283 | def exportXml(fits, progress, callback): |
| 284 | doc = xml.dom.minidom.Document() |
| 285 | fittings = doc.createElement("fittings") |
| 286 | # fit count |
| 287 | fit_count = len(fits) |
| 288 | fittings.setAttribute("count", "%s" % fit_count) |
| 289 | doc.appendChild(fittings) |
| 290 | |
| 291 | def addMutantAttributes(node, mutant): |
| 292 | node.setAttribute("base_type", mutant.baseItem.name) |
| 293 | node.setAttribute("mutaplasmid", mutant.mutaplasmid.item.name) |
| 294 | node.setAttribute("mutated_attrs", renderMutantAttrs(mutant)) |
| 295 | |
| 296 | for i, fit in enumerate(fits): |
| 297 | if progress: |
| 298 | if progress.userCancelled: |
| 299 | return None |
| 300 | processedFits = i + 1 |
| 301 | progress.current = processedFits |
| 302 | progress.message = "converting to xml (%s/%s) %s" % (processedFits, fit_count, fit.ship.name) |
| 303 | try: |
| 304 | fitting = doc.createElement("fitting") |
| 305 | fitting.setAttribute("name", fit.name) |
| 306 | fittings.appendChild(fitting) |
| 307 | description = doc.createElement("description") |
| 308 | # -- 170327 Ignored description -- |
| 309 | try: |
| 310 | notes = fit.notes # unicode |
| 311 | |
| 312 | if notes: |
| 313 | notes = notes[:397] + '...' if len(notes) > 400 else notes |
| 314 | |
| 315 | description.setAttribute( |
| 316 | "value", re.sub("(\r|\n|\r\n)+", "<br>", notes) if notes is not None else "" |
| 317 | ) |
| 318 | except (KeyboardInterrupt, SystemExit): |
| 319 | raise |
| 320 | except Exception as e: |
| 321 | pyfalog.warning("read description is failed, msg=%s\n" % e.args) |
| 322 | |
| 323 | fitting.appendChild(description) |
| 324 | shipType = doc.createElement("shipType") |
| 325 | shipType.setAttribute("value", fit.ship.name) |
| 326 | fitting.appendChild(shipType) |
| 327 | |
| 328 | charges = {} |
| 329 | slotNum = {} |
| 330 | for module in fit.modules: |
| 331 | if module.isEmpty: |
| 332 | continue |
| 333 | |
| 334 | slot = module.slot |
| 335 | |
| 336 | if slot == FittingSlot.SUBSYSTEM: |
| 337 | # Order of subsystem matters based on this attr. See GH issue #130 |
| 338 | slotId = module.getModifiedItemAttr("subSystemSlot") - 125 |
| 339 | else: |
| 340 | if slot not in slotNum: |
no test coverage detected