NOTE: Since it is meaningless unless a correct ship object can be constructed, process flow changed
(fitting, sMkt, b_localized)
| 62 | |
| 63 | |
| 64 | def _resolve_ship(fitting, sMkt, b_localized): |
| 65 | # type: (xml.dom.minidom.Element, service.market.Market, bool) -> eos.saveddata.fit.Fit |
| 66 | """ NOTE: Since it is meaningless unless a correct ship object can be constructed, |
| 67 | process flow changed |
| 68 | """ |
| 69 | # ------ Confirm ship |
| 70 | # <localized hint="Maelstrom">Maelstrom</localized> |
| 71 | shipType = fitting.getElementsByTagName("shipType").item(0).getAttribute("value") |
| 72 | anything = None |
| 73 | if b_localized: |
| 74 | try: |
| 75 | # expect an official name, emergency cache |
| 76 | shipType, anything = _extract_match(shipType) |
| 77 | except ExtractingError: |
| 78 | pass |
| 79 | |
| 80 | limit = 2 |
| 81 | ship = None |
| 82 | while True: |
| 83 | must_retry = False |
| 84 | try: |
| 85 | try: |
| 86 | ship = Ship(sMkt.getItem(shipType)) |
| 87 | except ValueError: |
| 88 | ship = Citadel(sMkt.getItem(shipType)) |
| 89 | except (KeyboardInterrupt, SystemExit): |
| 90 | raise |
| 91 | except Exception as e: |
| 92 | pyfalog.warning("Caught exception on _resolve_ship") |
| 93 | pyfalog.error(e) |
| 94 | limit -= 1 |
| 95 | if limit == 0: |
| 96 | break |
| 97 | shipType = anything |
| 98 | must_retry = True |
| 99 | if not must_retry: |
| 100 | break |
| 101 | |
| 102 | if ship is None: |
| 103 | raise Exception("cannot resolve ship type.") |
| 104 | |
| 105 | fitobj = Fit(ship=ship) |
| 106 | # ------ Confirm fit name |
| 107 | anything = fitting.getAttribute("name") |
| 108 | # 2017/03/29 NOTE: |
| 109 | # if fit name contained "<" or ">" then reprace to named html entity by EVE client |
| 110 | # if re.search(RE_LTGT, anything): |
| 111 | if "<" in anything or ">" in anything: |
| 112 | anything = replace_ltgt(anything) |
| 113 | fitobj.name = anything |
| 114 | |
| 115 | return fitobj |
| 116 | |
| 117 | |
| 118 | def _resolve_module(hardware, sMkt, b_localized): |
no test coverage detected