ZahirJS commited on
Commit
1683988
·
verified ·
1 Parent(s): 77c70c2

Update wbs_diagram_generator.py

Browse files
Files changed (1) hide show
  1. 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
- # Save to temporary file
236
- with NamedTemporaryFile(delete=False, suffix='.png') as tmp:
237
- dot.render(tmp.name, format='png', cleanup=True)
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"