INNER CODE UNIT · Python

check_chain_file

YutaSugimura/DeFi-Map · scripts/check_format.py:51

def check_chain_file(path: Path) -> int:
    lines = path.read_text(encoding="utf-8").splitlines()
    if not lines or not lines[0].startswith("# DeFi on "):
        err(f"{path}: first line must be a '# DeFi on ...' title")

    section_indices: list[int] = []
    rows = 0
    current = None
    for n, line in enumerate(lines, 1):
        if line.startswith("## "):
            current = line[3:].strip()
            if current not in CANONICAL_ORDER:
                err(f"{path}:{n}: unknown category {current!r} (see CONTRIBUTING.md#categories)")
                continue
            idx = CANONICAL_ORDER.index(current)
            if section_indices and idx <= section_indices[-1]:
                err(f"{path}:{n}: category {current!r} out of canonical order")
            section_indices.append(idx)

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…