Skip to content

Commit 71d8b00

Browse files
committed
fix(converters): converter error when files have been converted
1 parent 9719965 commit 71d8b00

File tree

1 file changed

+27
-30
lines changed

1 file changed

+27
-30
lines changed

automated_security_helper/core/phases/convert_phase.py

Lines changed: 27 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"""Implementation of the Convert phase."""
22

3+
from pathlib import Path
34
from automated_security_helper.base.engine_phase import EnginePhase
45
from automated_security_helper.core.enums import ExecutionPhase
56
from automated_security_helper.models.asharp_model import (
@@ -195,37 +196,33 @@ def _execute_phase(
195196
# Call convert method directly - converters should handle finding their own targets
196197
ASH_LOGGER.debug(f"Calling convert() on {display_name}")
197198
# Pass the source directory as the target
198-
convert_result = plugin_instance.convert()
199-
200-
if convert_result:
201-
if isinstance(convert_result, list):
202-
ASH_LOGGER.debug(
203-
f"Converter {display_name} returned {len(convert_result)} paths"
204-
)
205-
plugin_converted_paths.extend(convert_result)
206-
converted_paths.extend(convert_result)
207-
208-
# Update converter task to 100%
209-
self.progress_display.update_task(
210-
phase=ExecutionPhase.CONVERT,
211-
task_id=converter_task,
212-
completed=100,
213-
description=f"[green]({display_name}) Converted {len(convert_result)} files",
214-
)
215-
else:
216-
ASH_LOGGER.debug(
217-
f"Converter {display_name} returned a single path: {convert_result}"
218-
)
219-
plugin_converted_paths.append(convert_result)
220-
converted_paths.append(convert_result)
221-
222-
# Update converter task to 100%
223-
self.progress_display.update_task(
224-
phase=ExecutionPhase.CONVERT,
225-
task_id=converter_task,
226-
completed=100,
227-
description=f"[green]({display_name}) Converted 1 file",
199+
convert_result_initial = plugin_instance.convert()
200+
# Ensure all convert_result are strings in case some are Paths
201+
convert_result = []
202+
if convert_result_initial is not None:
203+
convert_result = [
204+
Path(item).as_posix()
205+
for item in (
206+
convert_result_initial
207+
if isinstance(convert_result_initial, list)
208+
else [convert_result_initial]
228209
)
210+
]
211+
212+
if isinstance(convert_result, list) and len(convert_result) > 0:
213+
ASH_LOGGER.debug(
214+
f"Converter {display_name} returned {len(convert_result)} paths"
215+
)
216+
plugin_converted_paths.extend(convert_result)
217+
converted_paths.extend(convert_result)
218+
219+
# Update converter task to 100%
220+
self.progress_display.update_task(
221+
phase=ExecutionPhase.CONVERT,
222+
task_id=converter_task,
223+
completed=100,
224+
description=f"[green]({display_name}) Converted {len(convert_result)} files",
225+
)
229226
else:
230227
ASH_LOGGER.debug(
231228
f"Converter {display_name} returned None or empty result"

0 commit comments

Comments
 (0)