Update wbs_diagram_generator.py
Browse files- wbs_diagram_generator.py +4 -5
wbs_diagram_generator.py
CHANGED
@@ -4,7 +4,7 @@ from tempfile import NamedTemporaryFile
|
|
4 |
import os
|
5 |
from graph_generator_utils import add_nodes_and_edges
|
6 |
|
7 |
-
def generate_wbs_diagram(json_input: str) -> str:
|
8 |
"""
|
9 |
Generates a Work Breakdown Structure (WBS) Diagram from JSON input.
|
10 |
|
@@ -232,10 +232,9 @@ def generate_wbs_diagram(json_input: str) -> str:
|
|
232 |
if 'tasks' in phase and isinstance(phase['tasks'], list):
|
233 |
_add_wbs_nodes_recursive(phase_id, phase['tasks'], phase_depth + 1)
|
234 |
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
return tmp.name + '.png'
|
239 |
|
240 |
except json.JSONDecodeError:
|
241 |
return "Error: Invalid JSON format"
|
|
|
4 |
import os
|
5 |
from graph_generator_utils import add_nodes_and_edges
|
6 |
|
7 |
+
def generate_wbs_diagram(json_input: str, output_format: str) -> str:
|
8 |
"""
|
9 |
Generates a Work Breakdown Structure (WBS) Diagram from JSON input.
|
10 |
|
|
|
232 |
if 'tasks' in phase and isinstance(phase['tasks'], list):
|
233 |
_add_wbs_nodes_recursive(phase_id, phase['tasks'], phase_depth + 1)
|
234 |
|
235 |
+
with NamedTemporaryFile(delete=False, suffix=f'.{output_format}') as tmp:
|
236 |
+
dot.render(tmp.name, format=output_format, cleanup=True)
|
237 |
+
return f"{tmp.name}.{output_format}"
|
|
|
238 |
|
239 |
except json.JSONDecodeError:
|
240 |
return "Error: Invalid JSON format"
|