(lines)
| 241 | |
| 242 | |
| 243 | def importEft(lines): |
| 244 | lines = _importPrepare(lines) |
| 245 | try: |
| 246 | fit = _importCreateFit(lines) |
| 247 | except EftImportError: |
| 248 | return |
| 249 | |
| 250 | aFit = AbstractFit() |
| 251 | aFit.mutations = importGetMutationData(lines) |
| 252 | |
| 253 | stubPattern = r'^\[.+?\]$' |
| 254 | modulePattern = r'^(?P<typeName>{0}+?)(,\s*(?P<chargeName>{0}+?))?(?P<offline>\s*/(OFFLINE|offline))?(\s*\[(?P<mutation>\d+?)\])?$'.format(NAME_CHARS) |
| 255 | droneCargoPattern = r'^(?P<typeName>{}+?) x(?P<amount>\d+?)(\s*\[(?P<mutation>\d+?)\])?$'.format(NAME_CHARS) |
| 256 | |
| 257 | sections = [] |
| 258 | for section in _importSectionIter(lines): |
| 259 | for line in section.lines: |
| 260 | # Stub line |
| 261 | if re.match(stubPattern, line): |
| 262 | section.itemSpecs.append(None) |
| 263 | continue |
| 264 | # Items with quantity specifier |
| 265 | m = re.match(droneCargoPattern, line) |
| 266 | if m: |
| 267 | try: |
| 268 | itemSpec = MultiItemSpec(m.group('typeName')) |
| 269 | # Items which cannot be fetched are considered as stubs |
| 270 | except EftImportError: |
| 271 | section.itemSpecs.append(None) |
| 272 | else: |
| 273 | itemSpec.amount = int(m.group('amount')) |
| 274 | section.itemSpecs.append(itemSpec) |
| 275 | if m.group('mutation'): |
| 276 | itemSpec.mutationIdx = int(m.group('mutation')) |
| 277 | continue |
| 278 | # All other items |
| 279 | m = re.match(modulePattern, line) |
| 280 | if m: |
| 281 | try: |
| 282 | itemSpec = RegularItemSpec(m.group('typeName'), chargeName=m.group('chargeName')) |
| 283 | # Items which cannot be fetched are considered as stubs |
| 284 | except EftImportError: |
| 285 | section.itemSpecs.append(None) |
| 286 | else: |
| 287 | if m.group('offline'): |
| 288 | itemSpec.offline = True |
| 289 | if m.group('mutation'): |
| 290 | itemSpec.mutationIdx = int(m.group('mutation')) |
| 291 | section.itemSpecs.append(itemSpec) |
| 292 | continue |
| 293 | _clearTail(section.itemSpecs) |
| 294 | sections.append(section) |
| 295 | |
| 296 | hasDroneBay = any(s.isDroneBay for s in sections) |
| 297 | hasFighterBay = any(s.isFighterBay for s in sections) |
| 298 | for section in sections: |
| 299 | if section.isModuleRack: |
| 300 | aFit.addModules(section.itemSpecs) |
no test coverage detected