Files
DEMO-AGENT/review_agent/management/commands/regulatory_rules_check.py

28 lines
1012 B
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
from __future__ import annotations
from django.core.management.base import BaseCommand
from review_agent.regulatory_review.services.rule_loader import check_rule_version
class Command(BaseCommand):
help = "检查 NMPA 法规核查 YAML 规则与数据库版本记录。"
def add_arguments(self, parser):
parser.add_argument(
"--no-create",
action="store_true",
help="缺少数据库记录时只报告 missing不创建记录。",
)
def handle(self, *args, **options):
result = check_rule_version(update_missing=not options["no_create"])
self.stdout.write(
f"{result.code}: {result.status}; yaml_hash={result.current_hash}; "
f"db_hash={result.database_hash or '-'}; path={result.path}"
)
if result.status == "mismatch":
self.stdout.write(
self.style.WARNING("YAML 与数据库记录不一致,请人工确认后更新规则版本记录。")
)