Skip to content

Commit c9bd100

Browse files
authored
Merge pull request #84 from ppfeufer/bug/ship-with-cosmic-sig-like-name-fails-dscan-parsing
2 parents 604663e + da84618 commit c9bd100

File tree

2 files changed

+21
-8
lines changed

2 files changed

+21
-8
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ Section Order:
4242
### Fixed
4343

4444
- zKillboard Link for corporations in scan results (Fixing #81)
45+
- Ship with cosmic sig-like name makes parsing fail (Fixing #82)
4546

4647
## \[2.0.0\] - 2024-03-16
4748

aa_intel_tool/parser/module/dscan.py

+20-8
Original file line numberDiff line numberDiff line change
@@ -286,32 +286,44 @@ def _get_scan_details(scan_data: list) -> tuple:
286286
:rtype:
287287
"""
288288

289+
# AA Intel Tool
290+
from aa_intel_tool.constants import ( # pylint: disable=import-outside-toplevel
291+
REGEX_PATTERN,
292+
)
293+
289294
ansiblex_destination = None
290295
counter = {"all": {}, "ongrid": {}, "offgrid": {}, "type": {}}
291296
eve_ids = {"all": [], "ongrid": [], "offgrid": []}
292297

293298
# Let's split this list up
294299
#
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
299304
#
300305
# Loop through all lines
301306
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))
304316

305317
counter["all"][entry_id] = counter["all"].get(entry_id, 0) + 1
306318

307319
# Check if the entry is "on grid" or not
308-
if _is_on_grid(line[3]):
320+
if _is_on_grid(line.group(4)):
309321
counter["ongrid"][entry_id] = counter["ongrid"].get(entry_id, 0) + 1
310322

311323
# If it is an Ansiblex Jump Gate, get its destination system
312324
if entry_id == UpwellStructureId.ANSIBLEX_JUMP_GATE:
313325
ansiblex_destination = _get_ansiblex_jumpgate_destination(
314-
ansiblex_name=line[1]
326+
ansiblex_name=line.group(2)
315327
)
316328

317329
eve_ids["ongrid"].append(entry_id)

0 commit comments

Comments
 (0)