(text, progress)
| 155 | |
| 156 | |
| 157 | def 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: |
no test coverage detected