CodeSampleX

샘플

packaging 26.3: metadata.parse_email

검증된 샘플 — pypi packaging 26.3: metadata.parse_email. python 3.12 · linux debian/x64 · docker에서 contract를 실행해 통과했습니다: parse_email parses standard string…

sha256:8cf81921c0da0552abff37fb23ac56aca9153ad023ad8c6330b7bb1196d12936

이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다. 통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다. MIT-0

실행 증거

선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.

증거 기준
서명된 컨트랙트 통과
검증 영수증
1
빌드한 서명 키
1
선언된 환경 linux 24 · ubuntu · glibc 2.39 x64 pip

검증 실행 환경

환경 컨트랙트 단계 실행일
python 3.12 · linux debian/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · python@1python:3.12-slim@sha256:09f7da3bc104…
2026-09-02

케이스

HOW
목표
verify packaging.metadata.parse_email in pkg:pypi/packaging@26.3
패키지
심벌
  • packaging.metadata.parse_email
생성일
2026-09-02T13:36:31Z

컨트랙트

  1. parse_email parses standard string distribution metadata headers and payload description into RawMetadata
  2. parse_email parses distribution metadata from raw bytes input
  3. parse_email structures multi-use metadata fields like classifiers and requires_dist as lists
  4. parse_email parses Project-URL headers into a dictionary mapping labels to URLs
  5. parse_email places unrecognized headers and duplicate single-value fields into the unparsed dictionary

파일

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

소스 아티팩트 내려받기 (tar.gz)

소스

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 packaging.metadata.parse_email in pkg:pypi/packaging@26.3
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:pypi/packaging@26.3
Demonstrate these symbols/APIs:
  - packaging.metadata.parse_email

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:f0bad6d94017f89d724a558406de6acde8c93ea3bef3e9d1890c44ccf661bc6f","contract":["parse_email parses standard string distribution metadata headers and payload description into RawMetadata","parse_email parses distribution metadata from raw bytes input","parse_email structures multi-use metadata fields like classifiers and requires_dist as lists","parse_email parses Project-URL headers into a dictionary mapping labels to URLs","parse_email places unrecognized headers and duplicate single-value fields into the unparsed dictionary"],"goal":"verify packaging.metadata.parse_email in pkg:pypi/packaging@26.3","kind":"HOW","packages":["pkg:pypi/packaging@26.3"],"schemaVersion":1,"symbols":["packaging.metadata.parse_email"]},"contractCommand":["python","test/contract.py"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"pypi","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"pip","schemaVersion":1},"license":"MIT-0","packages":["pkg:pypi/packaging@26.3"],"schemaVersion":1,"subject":"pkg:pypi/packaging@26.3","symbols":["packaging.metadata.parse_email"],"verifierAdapter":"python@1"}
pyproject.toml
[project]
name = "verify-packaging-parse-email"
version = "0.1.0"
dependencies = [
    "packaging==26.3",
]
requirements.txt
packaging==26.3
spec.json
{
  "schemaVersion": 1,
  "goal": "verify packaging.metadata.parse_email in pkg:pypi/packaging@26.3",
  "kind": "HOW",
  "packages": [
    "pkg:pypi/packaging@26.3"
  ],
  "symbols": [
    "packaging.metadata.parse_email"
  ]
}
test/contract.py
from packaging.metadata import parse_email


def test_parse_email_string_metadata():
    # Assertion 1: parse_email parses standard string distribution metadata headers and payload description into RawMetadata
    metadata_text = """Metadata-Version: 2.3
Name: demo-pkg
Version: 1.0.0
Summary: A lightweight demo package
Author-email: Developer <dev@example.com>
Description-Content-Type: text/markdown

# Demo Package
Detailed description content.
"""
    raw_metadata, unparsed = parse_email(metadata_text)
    assert raw_metadata["metadata_version"] == "2.3"
    assert raw_metadata["name"] == "demo-pkg"
    assert raw_metadata["version"] == "1.0.0"
    assert raw_metadata["summary"] == "A lightweight demo package"
    assert raw_metadata["author_email"] == "Developer <dev@example.com>"
    assert raw_metadata["description_content_type"] == "text/markdown"
    assert raw_metadata["description"] == "# Demo Package\nDetailed description content.\n"
    assert unparsed == {}


def test_parse_email_bytes_input():
    # Assertion 2: parse_email parses distribution metadata from raw bytes input
    metadata_bytes = b"Metadata-Version: 2.2\nName: binary-metadata-pkg\nVersion: 2.1.0\n"
    raw_metadata, unparsed = parse_email(metadata_bytes)
    assert raw_metadata["metadata_version"] == "2.2"
    assert raw_metadata["name"] == "binary-metadata-pkg"
    assert raw_metadata["version"] == "2.1.0"
    assert unparsed == {}


def test_parse_email_multi_use_fields():
    # Assertion 3: parse_email structures multi-use metadata fields like classifiers and requires_dist as lists
    metadata_text = """Metadata-Version: 2.1
Name: multi-field-pkg
Version: 0.5.0
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Requires-Dist: packaging >= 20.0
Requires-Dist: urllib3 < 3.0; extra == "http"
Dynamic: dependencies
Dynamic: classifiers
"""
    raw_metadata, unparsed = parse_email(metadata_text)
    assert raw_metadata["classifiers"] == [
        "Programming Language :: Python :: 3",
        "License :: OSI Approved :: MIT License",
    ]
    assert raw_metadata["requires_dist"] == [
        "packaging >= 20.0",
        'urllib3 < 3.0; extra == "http"',
    ]
    assert raw_metadata["dynamic"] == ["dependencies", "classifiers"]
    assert unparsed == {}


def test_parse_email_project_urls():
    # Assertion 4: parse_email parses Project-URL headers into a dictionary mapping labels to URLs
    metadata_text = """Metadata-Version: 2.1
Name: url-pkg
Version: 1.0.0
Project-URL: Homepage, https://example.com/project
Project-URL: Documentation, https://example.com/docs
Project-URL: Repository, https://example.com/repo
"""
    raw_metadata, unparsed = parse_email(metadata_text)
    assert raw_metadata["project_urls"] == {
        "Homepage": "https://example.com/project",
        "Documentation": "https://example.com/docs",
        "Repository": "https://example.com/repo",
    }
    assert unparsed == {}


def test_parse_email_unrecognized_and_duplicate_fields():
    # Assertion 5: parse_email places unrecognized headers and duplicate single-value fields into the unparsed dictionary
    metadata_text = """Metadata-Version: 2.1
Name: duplicate-test-pkg
Name: second-name-value
Version: 1.0.0
X-Custom-Header: custom-val-1
X-Custom-Header: custom-val-2
"""
    raw_metadata, unparsed = parse_email(metadata_text)
    assert raw_metadata["version"] == "1.0.0"
    assert "name" not in raw_metadata
    assert unparsed["name"] == ["duplicate-test-pkg", "second-name-value"]
    assert unparsed["x-custom-header"] == ["custom-val-1", "custom-val-2"]


def main():
    test_parse_email_string_metadata()
    test_parse_email_bytes_input()
    test_parse_email_multi_use_fields()
    test_parse_email_project_urls()
    test_parse_email_unrecognized_and_duplicate_fields()
    print("All contract assertions passed.")


if __name__ == "__main__":
    main()

오리진 시더

익명