|
1 | 1 | """Implementation of the Convert phase."""
|
2 | 2 |
|
| 3 | +from pathlib import Path |
3 | 4 | from automated_security_helper.base.engine_phase import EnginePhase
|
4 | 5 | from automated_security_helper.core.enums import ExecutionPhase
|
5 | 6 | from automated_security_helper.models.asharp_model import (
|
@@ -195,37 +196,33 @@ def _execute_phase(
|
195 | 196 | # Call convert method directly - converters should handle finding their own targets
|
196 | 197 | ASH_LOGGER.debug(f"Calling convert() on {display_name}")
|
197 | 198 | # 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] |
228 | 209 | )
|
| 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 | + ) |
229 | 226 | else:
|
230 | 227 | ASH_LOGGER.debug(
|
231 | 228 | f"Converter {display_name} returned None or empty result"
|
|
0 commit comments