Skip to content

Commit 09eb89b

Browse files
refactor(config): output formatting with 2 supporting modules
changes: - file: validate_toon.py area: core added: [_print_comparison_summary, _compare_all_aspects, _run_comparison_mode, _run_single_file_mode] modified: [main] stats: lines: "+84/-88 (net -4)" files: 2 complexity: "Large structural change (normalized)"
1 parent c2342cd commit 09eb89b

8 files changed

Lines changed: 94 additions & 93 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
## [Unreleased]
22

3+
## [0.5.110] - 2026-04-18
4+
5+
### Other
6+
- Update validate_toon.py
7+
38
## [0.5.109] - 2026-04-18
49

510
### Docs

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
## AI Cost Tracking
55

6-
![PyPI](https://img.shields.io/badge/pypi-costs-blue) ![Version](https://img.shields.io/badge/version-0.5.109-blue) ![Python](https://img.shields.io/badge/python-3.9+-blue) ![License](https://img.shields.io/badge/license-Apache--2.0-green)
6+
![PyPI](https://img.shields.io/badge/pypi-costs-blue) ![Version](https://img.shields.io/badge/version-0.5.110-blue) ![Python](https://img.shields.io/badge/python-3.9+-blue) ![License](https://img.shields.io/badge/license-Apache--2.0-green)
77
![AI Cost](https://img.shields.io/badge/AI%20Cost-$7.50-orange) ![Human Time](https://img.shields.io/badge/Human%20Time-53.7h-blue) ![Model](https://img.shields.io/badge/Model-openrouter%2Fqwen%2Fqwen3--coder--next-lightgrey)
88

99
- 🤖 **LLM usage:** $7.5000 (154 commits)

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.5.109
1+
0.5.110

code2llm/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
and entity resolution with multilingual support.
99
"""
1010

11-
__version__ = "0.5.109"
11+
__version__ = "0.5.110"
1212
__author__ = "STTS Project"
1313

1414
# Core analysis components (lightweight, always needed)

code2llm/nlp/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
with multilingual support and fuzzy matching.
55
"""
66

7-
__version__ = "0.5.109"
7+
__version__ = "0.5.110"
88

99
from .pipeline import NLPPipeline
1010
from .normalization import QueryNormalizer

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "code2llm"
7-
version = "0.5.109"
7+
version = "0.5.110"
88
description = "High-performance Python code flow analysis with optimized TOON format - CFG, DFG, call graphs, and intelligent code queries"
99
readme = "README.md"
1010
requires-python = ">=3.8"

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import os
55

66
# Read version
7-
version = "0.5.108"
7+
version = "0.5.109"
88

99
# Read long description
1010
def read_readme():

validate_toon.py

Lines changed: 83 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -294,101 +294,97 @@ def validate_toon_completeness(toon_data):
294294

295295
return all_present
296296

297+
def _run_single_file_mode(file_path: Path) -> int:
298+
"""Single file mode - validate TOON format structure only."""
299+
if not file_path.exists():
300+
print(f"Error: {file_path} not found")
301+
return 1
302+
303+
print(f"🔍 Validating TOON format: {file_path.name}")
304+
print("=" * 60)
305+
306+
data = load_file(file_path)
307+
if not data:
308+
print("Error: Could not load file")
309+
return 1
310+
311+
is_valid = validate_toon_completeness(data)
312+
313+
print("\n" + "=" * 60)
314+
print("📋 TOON FORMAT VALIDATION SUMMARY:")
315+
print("=" * 60)
316+
317+
status = "✅ PASS" if is_valid else "❌ FAIL"
318+
print(f"{status} TOON Structure")
319+
print("\n" + ("🎉 TOON FORMAT VALID!" if is_valid else "⚠️ TOON FORMAT ISSUES!"))
320+
321+
return 0 if is_valid else 1
322+
323+
324+
def _run_comparison_mode(yaml_path: Path, toon_path: Path) -> int:
325+
"""Comparison mode - compare YAML vs TOON."""
326+
if not yaml_path.exists():
327+
print(f"Error: {yaml_path} not found")
328+
return 1
329+
330+
if not toon_path.exists():
331+
print(f"Error: {toon_path} not found")
332+
return 1
333+
334+
print(f"🔍 Validating: {yaml_path.name} vs {toon_path.name}")
335+
print("=" * 60)
336+
337+
yaml_data = load_yaml(yaml_path)
338+
toon_data = load_file(toon_path)
339+
340+
if not yaml_data or not toon_data:
341+
print("Error: Could not load one or both files")
342+
return 1
343+
344+
results = _compare_all_aspects(yaml_data, toon_data)
345+
_print_comparison_summary(results)
346+
347+
return 0 if all(passed for _, passed in results) else 1
348+
349+
350+
def _compare_all_aspects(yaml_data, toon_data) -> list:
351+
"""Compare all aspects of YAML vs TOON data."""
352+
return [
353+
("Basic Statistics", compare_basic_stats(yaml_data, toon_data)),
354+
("Functions", compare_functions(yaml_data, toon_data)),
355+
("Classes", compare_classes(yaml_data, toon_data)),
356+
("Modules", compare_modules(yaml_data, toon_data)),
357+
("TOON Structure", validate_toon_completeness(toon_data))
358+
]
359+
360+
361+
def _print_comparison_summary(results: list) -> None:
362+
"""Print comparison summary report."""
363+
print("\n" + "=" * 60)
364+
print("📋 FINAL VALIDATION SUMMARY:")
365+
print("=" * 60)
366+
367+
all_passed = True
368+
for test_name, passed in results:
369+
status = "✅ PASS" if passed else "❌ FAIL"
370+
print(f"{status} {test_name}")
371+
if not passed:
372+
all_passed = False
373+
374+
print("\n" + ("🎉 ALL TESTS PASSED!" if all_passed else "⚠️ SOME TESTS FAILED!"))
375+
376+
297377
def main():
298378
"""Main validation function."""
299379
if len(sys.argv) == 2:
300-
# Single file mode - validate TOON format structure only
301-
file_path = Path(sys.argv[1])
302-
303-
if not file_path.exists():
304-
print(f"Error: {file_path} not found")
305-
sys.exit(1)
306-
307-
print(f"🔍 Validating TOON format: {file_path.name}")
308-
print("=" * 60)
309-
310-
# Load file (auto-detect format)
311-
data = load_file(file_path)
312-
313-
if not data:
314-
print("Error: Could not load file")
315-
sys.exit(1)
316-
317-
# Validate structure
318-
is_valid = validate_toon_completeness(data)
319-
320-
# Final summary
321-
print("\n" + "=" * 60)
322-
print("📋 TOON FORMAT VALIDATION SUMMARY:")
323-
print("=" * 60)
324-
325-
status = "✅ PASS" if is_valid else "❌ FAIL"
326-
print(f"{status} TOON Structure")
327-
328-
print("\n" + ("🎉 TOON FORMAT VALID!" if is_valid else "⚠️ TOON FORMAT ISSUES!"))
329-
330-
return 0 if is_valid else 1
331-
380+
return _run_single_file_mode(Path(sys.argv[1]))
332381
elif len(sys.argv) == 3:
333-
# Comparison mode - compare YAML vs TOON
334-
yaml_path = Path(sys.argv[1])
335-
toon_path = Path(sys.argv[2])
336-
337-
if not yaml_path.exists():
338-
print(f"Error: {yaml_path} not found")
339-
sys.exit(1)
340-
341-
if not toon_path.exists():
342-
print(f"Error: {toon_path} not found")
343-
sys.exit(1)
344-
345-
print(f"🔍 Validating: {yaml_path.name} vs {toon_path.name}")
346-
print("=" * 60)
347-
348-
# Load both files
349-
yaml_data = load_yaml(yaml_path)
350-
toon_data = load_file(toon_path) # Auto-detect TOON format
351-
352-
if not yaml_data or not toon_data:
353-
print("Error: Could not load one or both files")
354-
sys.exit(1)
355-
356-
# Compare all aspects
357-
stats_match = compare_basic_stats(yaml_data, toon_data)
358-
functions_match = compare_functions(yaml_data, toon_data)
359-
classes_match = compare_classes(yaml_data, toon_data)
360-
modules_match = compare_modules(yaml_data, toon_data)
361-
toon_valid = validate_toon_completeness(toon_data)
362-
363-
# Final summary
364-
print("\n" + "=" * 60)
365-
print("📋 FINAL VALIDATION SUMMARY:")
366-
print("=" * 60)
367-
368-
results = [
369-
("Basic Statistics", stats_match),
370-
("Functions", functions_match),
371-
("Classes", classes_match),
372-
("Modules", modules_match),
373-
("TOON Structure", toon_valid)
374-
]
375-
376-
all_passed = True
377-
for test_name, passed in results:
378-
status = "✅ PASS" if passed else "❌ FAIL"
379-
print(f"{status} {test_name}")
380-
if not passed:
381-
all_passed = False
382-
383-
print("\n" + ("🎉 ALL TESTS PASSED!" if all_passed else "⚠️ SOME TESTS FAILED!"))
384-
385-
return 0 if all_passed else 1
386-
382+
return _run_comparison_mode(Path(sys.argv[1]), Path(sys.argv[2]))
387383
else:
388384
print("Usage:")
389385
print(" python validate_toon.py <analysis.toon> # Validate TOON only")
390386
print(" python validate_toon.py <analysis.yaml> <analysis.toon> # Compare both formats")
391-
sys.exit(1)
387+
return 1
392388

393389
if __name__ == '__main__':
394390
sys.exit(main())

0 commit comments

Comments
 (0)