@@ -286,32 +286,44 @@ def _get_scan_details(scan_data: list) -> tuple:
286
286
:rtype:
287
287
"""
288
288
289
+ # AA Intel Tool
290
+ from aa_intel_tool .constants import ( # pylint: disable=import-outside-toplevel
291
+ REGEX_PATTERN ,
292
+ )
293
+
289
294
ansiblex_destination = None
290
295
counter = {"all" : {}, "ongrid" : {}, "offgrid" : {}, "type" : {}}
291
296
eve_ids = {"all" : [], "ongrid" : [], "offgrid" : []}
292
297
293
298
# Let's split this list up
294
299
#
295
- # line[0] => Item ID
296
- # line[1] => Name
297
- # line[2] => Ship Class / Structure Type
298
- # line[3] => Distance
300
+ # line.group(1) => Item ID
301
+ # line.group(2) => Name
302
+ # line.group(3) => Ship Class / Structure Type
303
+ # line.group(4) => Distance
299
304
#
300
305
# Loop through all lines
301
306
for entry in scan_data :
302
- line = re .split (pattern = r"\t+" , string = entry .rstrip ("\t " ))
303
- entry_id = int (line [0 ])
307
+ # Apparently you can copy/paste a tab into the ship name, which will cause the split by tab to fail.
308
+ # The regex is detecting the D-Scan correctly though. But splitting by tab might put the ship class as distance.
309
+ # See https://github.com/ppfeufer/aa-intel-tool/issues/82
310
+ #
311
+ # This is why we use re.search() to get the parts of the D-Scan entry, instead of re-split()
312
+ #
313
+ # Thanks CCP for sanitizing your inputs! 😂
314
+ line = re .search (pattern = REGEX_PATTERN ["dscan" ], string = entry )
315
+ entry_id = int (line .group (1 ))
304
316
305
317
counter ["all" ][entry_id ] = counter ["all" ].get (entry_id , 0 ) + 1
306
318
307
319
# Check if the entry is "on grid" or not
308
- if _is_on_grid (line [ 3 ] ):
320
+ if _is_on_grid (line . group ( 4 ) ):
309
321
counter ["ongrid" ][entry_id ] = counter ["ongrid" ].get (entry_id , 0 ) + 1
310
322
311
323
# If it is an Ansiblex Jump Gate, get its destination system
312
324
if entry_id == UpwellStructureId .ANSIBLEX_JUMP_GATE :
313
325
ansiblex_destination = _get_ansiblex_jumpgate_destination (
314
- ansiblex_name = line [ 1 ]
326
+ ansiblex_name = line . group ( 2 )
315
327
)
316
328
317
329
eve_ids ["ongrid" ].append (entry_id )
0 commit comments