Skip to content

anbeime/skill / skills/legal-assistant-skills-main/contract-review

contract-review

Verified

律师助理与法律助手、项目管理专家在审核合同、排查条款风险时必备。自动执行基础、商业、法律三层审查,仅添加批注不改原文,一键生成带批注合同、审查摘要、综合意见及业务流程图,让合同风控与业务梳理更高效专业。

scripts/ooxml/validation/base.py

View on GitHub
"""Lightweight validation helpers for Office XML documents."""

from __future__ import annotations

from pathlib import Path
from typing import Iterable

import defusedxml.ElementTree as ET


class BaseValidator:
    """Basic structural checks for unpacked Office documents."""

    required_files: Iterable[str] = ()

    def __init__(self, unpacked_dir: Path, original_file: Path, verbose: bool = False):
        self.unpacked_dir = Path(unpacked_dir)
        self.original_file = Path(original_file)
        self.verbose = verbose

    def validate(self) -> bool:
        if not self._check_required_files(self.required_files):
            return False
        return self._parse_xml_files(self.required_files)

    def _check_required_files(self, rel_paths: Iterable[str]) -> bool:
        missing = [p for p in rel_paths if not (self.unpacked_dir / p).exists()]
        if missing:
            if self.verbose:
                print(f"Missing required files: {missing}")
            return False
        return True

    def _parse_xml_files(self, rel_paths: Iterable[str]) -> bool:
        for rel_path in rel_paths:
            if not rel_path.endswith((".xml", ".rels")):
                continue
            file_path = self.unpacked_dir / rel_path
            try:
                ET.parse(file_path)
            except ET.ParseError as exc:
                if self.verbose:
                    print(f"Invalid XML in {rel_path}: {exc}")
                return False
        return True
receiving-code-reviewobra/superpowersUse when receiving code review feedback, before implementing suggestions, especially if feedback seems unclear or technically questionable - requires technical rigor and verification, not performative agreement or blind implementationStars: 322kUpdated Claude CodeCodexVerifiedInstall
requesting-code-reviewobra/superpowersUse when completing tasks, implementing major features, or before merging to verify work meets requirementsStars: 322kUpdated Claude CodeCodexVerifiedInstall
using-git-worktreesobra/superpowersUse when starting feature work that needs isolation from current workspace or before executing implementation plans - ensures an isolated workspace exists via native tools or git worktree fallbackStars: 322kUpdated Claude CodeCodexVerifiedInstall
verification-before-completionobra/superpowersUse when about to claim work is complete, fixed, or passing, before committing or creating PRs - requires running verification commands and confirming output before making any success claims; evidence before assertions alwaysStars: 322kUpdated Claude CodeCodexVerifiedInstall