CodeSampleX

Beispiel

pooch 1.9.0: make_registry

Verifiziertes Beispiel für pypi pooch 1.9.0: make_registry. Der Vertrag lief auf python 3.12 · linux alpine/x64 · docker und bestand.

sha256:1d8861dbe6460160ca28a6c76e1db5862bb2a686b491aaa674dd406777fd698b

Dieses Netzwerk bietet eine Sache: ein Sample, das baut. Es hat es in einer Sandbox ausgeführt und die signierte Quittung behalten. Es bewertet nichts und garantiert nichts — ob derselbe Code bei Ihnen baut, hat es nicht gemessen. Wie viele verschiedene Signaturschlüssel eine bestandene Vertragsquittung eingereicht haben. Einer ist der Autor allein; mehr als einer heißt, jemand anderes hat es auch gebaut. Ein Schlüssel wird selbst erzeugt und hat keine registrierte Identität dahinter — gezählt werden Schlüssel, nicht Personen. MIT-0

Ausführungsbelege

Die deklarierte Umgebung und die signierten Läufe stehen getrennt, damit Sie genau sehen, was dieses Sample ausgeführt hat und wo.

Beleggrundlage
Signierter Vertrag bestanden
Verifizierungsbelege
1
Signaturschlüssel, die es gebaut haben
1
Deklarierte Umgebung python linux 24 · ubuntu · glibc 2.39 x64 python python pip

Umgebungen der Verifizierungsläufe

Umgebung Contract Stufen Lauf
python 3.12 · linux alpine/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · python@1python:3.12-alpine@sha256:d09d15e60962…
2026-08-30

Fall

HOW
Ziel
verify pooch.make_registry in pkg:pypi/pooch@1.9.0
Pakete
Symbole
  • pooch.make_registry
Umgebung
python
Erstellt
2026-08-30T19:21:32Z

Contract

  1. make_registry scans a directory and writes a registry text file mapping relative POSIX file paths to their SHA-256 checksums.
  2. With recursive=True (default), make_registry traverses nested subdirectories and normalizes path separators to forward slashes.
  3. With recursive=False, make_registry only processes top-level files in the specified directory.
  4. make_registry handles empty directories by generating an empty registry file.
  5. The generated registry file can be parsed by Pooch.load_registry to populate dataset filenames and SHA-256 hashes.

Dateien

  • NOTES.md
  • PROMPT.md
  • csx.json
  • requirements.txt
  • spec.json
  • test/contract.py

Quellartefakt herunterladen (tar.gz)

Quelltext

NOTES.md
# pooch make_registry API

This sample pins `pooch` 1.9.0 and verifies `pooch.make_registry` for generating checksum registries of dataset files.

The contract verifies:
- `make_registry` scans a directory and writes a registry file with relative file paths and SHA-256 hashes.
- `recursive=True` (default) traverses nested subdirectories with forward slash path separators.
- `recursive=False` restricts the registry to files directly within the target directory.
- `make_registry` safely creates an empty registry file when targeting an empty directory.
- Generated registry files can be loaded by `Pooch.load_registry` into a pooch instance.
PROMPT.md
Clean-room public code sample — generation instructions

Write a brand-new, minimal, self-contained code sample in this clean-room directory.
Do not copy, paraphrase, or reference any existing project source. Work only from this spec.

A csx.json manifest scaffold already exists. Do not recreate it from memory. Preserve its case.goal, packages and symbols; fill its empty case.contract with exact assertions and correct its environment, commands and verifierAdapter for the files you generate.

Goal: verify pooch.make_registry in pkg:pypi/pooch@1.9.0
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:pypi/pooch@1.9.0
Demonstrate these symbols/APIs:
  - pooch.make_registry

Rules:
  - One focused purpose; the smallest project that proves the goal.
  - Include a contract test (test/contract.*) that runs OFFLINE and exits 0 exactly when the goal behavior works.
  - Pin every dependency with a lockfile so resolution is reproducible.
  - No secrets, credentials, or tokens. No real URLs (only example.com or localhost). No absolute paths.
  - No personal names, emails, company names, or project identifiers of any kind.
  - No binaries and no generated output (node_modules, dist, target, venv, .git, .env).
  - Keep it under 200 files and 256KB packed.
csx.json
{"case":{"caseId":"case:sha256:8a6234ec7dd2cc883d529a0b9d0e9b619a0e40ee993d5e421ca73741b3fc711b","contract":["make_registry scans a directory and writes a registry text file mapping relative POSIX file paths to their SHA-256 checksums.","With recursive=True (default), make_registry traverses nested subdirectories and normalizes path separators to forward slashes.","With recursive=False, make_registry only processes top-level files in the specified directory.","make_registry handles empty directories by generating an empty registry file.","The generated registry file can be parsed by Pooch.load_registry to populate dataset filenames and SHA-256 hashes."],"goal":"verify pooch.make_registry in pkg:pypi/pooch@1.9.0","kind":"HOW","packages":["pkg:pypi/pooch@1.9.0"],"schemaVersion":1,"symbols":["pooch.make_registry"]},"contractCommand":["python","test/contract.py"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"pypi","executionContext":"python","language":"python","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"pip","runtime":"python","schemaVersion":1},"license":"MIT-0","packages":["pkg:pypi/pooch@1.9.0"],"schemaVersion":1,"subject":"pkg:pypi/pooch@1.9.0","symbols":["pooch.make_registry"],"verifierAdapter":"python@1"}
requirements.txt
pooch==1.9.0
platformdirs==4.11.5
packaging==26.3
requests==2.34.2
urllib3==2.7.0
certifi==2026.7.22
charset-normalizer==3.5.1
idna==3.19
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pooch.make_registry in pkg:pypi/pooch@1.9.0",
  "kind": "HOW",
  "packages": [
    "pkg:pypi/pooch@1.9.0"
  ],
  "symbols": [
    "pooch.make_registry"
  ]
}
test/contract.py
import hashlib
from pathlib import Path
import tempfile
import pooch
from pooch import create, make_registry

# 1. Verify make_registry scans a directory and writes space-separated relative paths and SHA-256 hashes
with tempfile.TemporaryDirectory() as tmpdir:
    tmp_path = Path(tmpdir)
    data_dir = tmp_path / "data"
    data_dir.mkdir()
    sub_dir = data_dir / "subdir"
    sub_dir.mkdir()

    f1 = data_dir / "sample.txt"
    f1_content = b"Hello, Pooch registry!"
    f1.write_bytes(f1_content)
    f1_hash = hashlib.sha256(f1_content).hexdigest()

    f2 = sub_dir / "nested.csv"
    f2_content = b"col1,col2\n1,2\n"
    f2.write_bytes(f2_content)
    f2_hash = hashlib.sha256(f2_content).hexdigest()

    # Recursive make_registry (default recursive=True)
    rec_reg_file = tmp_path / "registry_rec.txt"
    make_registry(str(data_dir), str(rec_reg_file), recursive=True)
    assert rec_reg_file.is_file(), "Registry file must be created"

    lines = [
        line.strip()
        for line in rec_reg_file.read_text(encoding="utf-8").splitlines()
        if line.strip()
    ]
    assert len(lines) == 2, f"Expected 2 lines in recursive registry, got {len(lines)}"
    expected_entries = {
        "sample.txt": f1_hash,
        "subdir/nested.csv": f2_hash,
    }
    for line in lines:
        parts = line.split()
        assert len(parts) == 2, f"Invalid registry line format: {line}"
        fname, h = parts
        assert fname in expected_entries, f"Unexpected file in registry: {fname}"
        assert h == expected_entries[fname], f"Hash mismatch for {fname}: expected {expected_entries[fname]}, got {h}"

    # 2. Verify make_registry with recursive=False ignores subdirectories
    nonrec_reg_file = tmp_path / "registry_nonrec.txt"
    make_registry(str(data_dir), str(nonrec_reg_file), recursive=False)
    assert nonrec_reg_file.is_file(), "Non-recursive registry file must be created"
    nonrec_lines = [
        line.strip()
        for line in nonrec_reg_file.read_text(encoding="utf-8").splitlines()
        if line.strip()
    ]
    assert len(nonrec_lines) == 1, f"Expected 1 line in non-recursive registry, got {len(nonrec_lines)}"
    fname, h = nonrec_lines[0].split()
    assert fname == "sample.txt"
    assert h == f1_hash

    # 3. Verify make_registry handles empty directories
    empty_dir = tmp_path / "empty"
    empty_dir.mkdir()
    empty_reg_file = tmp_path / "registry_empty.txt"
    make_registry(str(empty_dir), str(empty_reg_file))
    assert empty_reg_file.is_file(), "Empty registry file must be created"
    assert empty_reg_file.read_text(encoding="utf-8") == "", "Empty directory should produce empty registry"

    # 4. Verify generated registry file can be loaded by pooch instance
    pup = create(path=tmp_path / "cache", base_url="https://example.com/data/", registry=None)
    pup.load_registry(str(rec_reg_file))
    assert len(pup.registry) == 2, f"Expected 2 registry entries in Pooch, got {len(pup.registry)}"
    assert pup.registry["sample.txt"] == f1_hash
    assert pup.registry["subdir/nested.csv"] == f2_hash

print("CONTRACT PASS: pooch.make_registry verified offline")

Ursprungs-Seeder

anonym