MCPcopy Create free account
hub / github.com/ResearAI/AutoFigure / repair_code

Function repair_code

autofigure/generator.py:906–923  ·  view source on GitHub ↗

Attempts to repair broken code based on output format. Args: code: The broken code (SVG or mxGraph XML). error_message: The parsing error message. output_format: 'svg' or 'mxgraphxml'. If None, uses CONFIG['OUTPUT_FORMAT']. Returns: The repaired code, o

(code: str, error_message: str, output_format: str = None)

Source from the content-addressed store, hash-verified

904
905
906def repair_code(code: str, error_message: str, output_format: str = None) -> Optional[str]:
907 """
908 Attempts to repair broken code based on output format.
909
910 Args:
911 code: The broken code (SVG or mxGraph XML).
912 error_message: The parsing error message.
913 output_format: 'svg' or 'mxgraphxml'. If None, uses CONFIG['OUTPUT_FORMAT'].
914
915 Returns:
916 The repaired code, or None after multiple attempts.
917 """
918 output_format = output_format or CONFIG.get('OUTPUT_FORMAT', 'svg')
919
920 if output_format == 'mxgraphxml':
921 return repair_mxgraphxml(code, error_message)
922 else:
923 return repair_svg(code, error_message)
924
925
926def validate_svg_syntax(svg_code: str) -> Tuple[bool, str]:

Callers 2

generate_initial_codeFunction · 0.85
improve_codeFunction · 0.85

Calls 2

repair_mxgraphxmlFunction · 0.85
repair_svgFunction · 0.85

Tested by

no test coverage detected