Fix code review issues: add PyYAML dependency and error handling

- Add pyyaml to requirements.txt
- Add error handling for missing PyYAML in manage.py and generate_sources_table.py
- Clarify test docstrings about JSON format in .yaml files
- Improve documentation of script dependencies

Co-authored-by: ArtemFilin1990 <221041513+ArtemFilin1990@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]andArtemFilin1990 committed 2025-12-31 13:15:48 +00:00
1 parent 5defada526
commit 2cd6b29d0e
4 files changed
+20 -3

No files matched your search

+6 -1
View File
@@ -143,7 +143,12 @@ def cmd_sources():
print("Sources Status")
print("=" * 60 + "\n")
import yaml
try:
import yaml
except ImportError:
print("❌ Error: PyYAML is not installed")
print("Install it with: pip install pyyaml")
return 1
sources_dir = REPO_ROOT / "sources"
categories = ["gost", "iso", "analogs", "brands", "skf"]
+1
View File
@@ -1 +1,2 @@
pytest>=7.4.0
pyyaml>=6.0
+11 -1
View File
@@ -5,6 +5,9 @@ Generate sources table for SOURCES.md.
This script reads all meta.yaml files from sources/ subdirectories
and generates a markdown table with source information.
Requirements:
- PyYAML (install with: pip install pyyaml)
Usage:
python scripts/generate_sources_table.py [--output SOURCES.md]
@@ -14,10 +17,17 @@ Examples:
"""
import argparse
import yaml
import sys
from pathlib import Path
from datetime import datetime
try:
import yaml
except ImportError:
print("❌ Error: PyYAML is not installed")
print("Install it with: pip install pyyaml")
sys.exit(1)
def load_sources_metadata(sources_dir):
"""Load all source metadata from meta.yaml files."""
+2 -1
View File
@@ -30,7 +30,7 @@ class TestSchemas(unittest.TestCase):
self.assertTrue(self.schemas_dir.is_dir(), "schemas/ should be a directory")
def test_all_schema_files_valid_json(self):
"""Test that all .yaml schema files contain valid JSON."""
"""Test that all .yaml schema files contain valid JSON format."""
schema_files = list(self.schemas_dir.glob("*.yaml"))
self.assertGreater(len(schema_files), 0, "Should have at least one schema file")
@@ -38,6 +38,7 @@ class TestSchemas(unittest.TestCase):
with self.subTest(schema=schema_file.name):
with open(schema_file, 'r', encoding='utf-8') as f:
try:
# Note: These .yaml files actually contain JSON format
data = json.load(f)
self.assertIsInstance(data, dict, f"{schema_file.name} should contain a JSON object")
except json.JSONDecodeError as e: