ZahirJS commited on
Commit
c06baf1
·
verified ·
1 Parent(s): daae0f4

Update concept_map_generator.py

Browse files
Files changed (1) hide show
  1. concept_map_generator.py +7 -3
concept_map_generator.py CHANGED
@@ -217,9 +217,13 @@ def generate_concept_map(json_input: str, output_format: str) -> str:
217
  # Add child nodes and edges recursively starting from depth 1
218
  add_nodes_and_edges(dot, 'central', data.get('nodes', []), current_depth=1, base_color=base_color)
219
 
220
- with NamedTemporaryFile(delete=False, suffix=f'.{output_format}') as tmp:
221
- dot.render(tmp.name, format=output_format, cleanup=True)
222
- return tmp.name
 
 
 
 
223
 
224
  except json.JSONDecodeError:
225
  return "Error: Invalid JSON format"
 
217
  # Add child nodes and edges recursively starting from depth 1
218
  add_nodes_and_edges(dot, 'central', data.get('nodes', []), current_depth=1, base_color=base_color)
219
 
220
+ with NamedTemporaryFile(delete=False) as tmp_file:
221
+ temp_base_path = tmp_file.name # path sin extensión, ej. /tmp/tmp_xyz
222
+
223
+ final_output_path = f"{temp_base_path}.{output_format}" # La ruta real que Graphviz creará
224
+
225
+ # dot.render() crea el archivo con la extensión correcta. cleanup=True elimina el archivo base (tmp_base_path).
226
+ dot.render(temp_base_path, format=output_format, cleanup=True)
227
 
228
  except json.JSONDecodeError:
229
  return "Error: Invalid JSON format"