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

Function _resolve_ship

service/port/xml.py:64–115  ·  view source on GitHub ↗

NOTE: Since it is meaningless unless a correct ship object can be constructed, process flow changed

(fitting, sMkt, b_localized)

Source from the content-addressed store, hash-verified

62
63
64def _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 "&lt;" in anything or "&gt;" in anything:
112 anything = replace_ltgt(anything)
113 fitobj.name = anything
114
115 return fitobj
116
117
118def _resolve_module(hardware, sMkt, b_localized):

Callers 1

importXmlFunction · 0.85

Calls 8

ShipClass · 0.90
CitadelClass · 0.90
FitClass · 0.90
replace_ltgtFunction · 0.90
_extract_matchFunction · 0.85
getAttributeMethod · 0.80
getItemMethod · 0.80
itemMethod · 0.45

Tested by

no test coverage detected