Skip to content

Commit ff1bd81

Browse files
committed
refactoring
1 parent 5a7acd5 commit ff1bd81

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

service/port/xml.py

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ def exportXml(fits, progress, callback):
296296
fittings = doc.createElement("fittings")
297297
# fit count
298298
fit_count = len(fits)
299-
fittings.setAttribute("count", "%s" % fit_count)
299+
fittings.setAttribute("count", str(fit_count))
300300
doc.appendChild(fittings)
301301

302302
def addMutantAttributes(node, mutant):
@@ -310,21 +310,18 @@ def addMutantAttributes(node, mutant):
310310
return None
311311
processedFits = i + 1
312312
progress.current = processedFits
313-
progress.message = "converting to xml (%s/%s) %s" % (processedFits, fit_count, fit.ship.name)
313+
progress.message = f"converting to xml ({processedFits}/{fit_count}) {fit.ship.name}"
314+
314315
try:
315316
fitting = doc.createElement("fitting")
316317
fitting.setAttribute("name", fit.name)
317318
fittings.appendChild(fitting)
318319
description = doc.createElement("description")
319320
# -- 170327 Ignored description --
320321
try:
321-
notes = fit.notes # unicode
322-
323-
if notes:
324-
notes = re.sub(r"(\r|\n|\r\n)", "<br>", notes)
325-
if len(notes) > EVE_FIT_NOTE_MAX:
326-
notes = notes[:EVE_FIT_NOTE_MAX - 3] + '...'
327-
322+
notes = re.sub(r"(\r|\n|\r\n)", "<br>", fit.notes or "")
323+
if len(notes) > EVE_FIT_NOTE_MAX:
324+
notes = notes[:EVE_FIT_NOTE_MAX - 3] + '...'
328325
description.setAttribute("value", notes)
329326
except (KeyboardInterrupt, SystemExit):
330327
raise
@@ -358,7 +355,7 @@ def addMutantAttributes(node, mutant):
358355
hardware.setAttribute("type", module.item.name)
359356
slotName = FittingSlot(slot).name.lower()
360357
slotName = slotName if slotName != "high" else "hi"
361-
hardware.setAttribute("slot", "%s slot %d" % (slotName, slotId))
358+
hardware.setAttribute("slot", f"{slotName} slot {slotId}")
362359
if module.isMutated:
363360
addMutantAttributes(hardware, module)
364361

@@ -392,16 +389,16 @@ def addMutantAttributes(node, mutant):
392389
charges[cargo.item.name] = 0
393390
charges[cargo.item.name] += cargo.amount
394391

395-
for name, qty in list(charges.items()):
392+
for name, qty in charges.items():
396393
hardware = doc.createElement("hardware")
397-
hardware.setAttribute("qty", "%d" % qty)
394+
hardware.setAttribute("qty", str(qty))
398395
hardware.setAttribute("slot", "cargo")
399396
hardware.setAttribute("type", name)
400397
fitting.appendChild(hardware)
401398
except (KeyboardInterrupt, SystemExit):
402399
raise
403400
except Exception as e:
404-
pyfalog.error("Failed on fitID: %d, message: %s" % e.message)
401+
pyfalog.error(f"Failed on fitID: {fit.ship.ID}, message: {e}")
405402
continue
406403
text = doc.toprettyxml()
407404

0 commit comments

Comments
 (0)