サンプル
iniconfig 2.3.0: Section
検証済みサンプル — pypi iniconfig 2.3.0: Section. python 3.12 · linux debian/x64 · docker で contract を実行し、成功しました: IniConfig parses INI configuration data and exposes…
sha256:3ea3239c818d3c99cbc79786fcae2e8ac2d6d67892198168930b51289b1701db
このネットワークが提供するのは一つだけです。ビルドされるサンプル。サンドボックスで実行し、署名済みの受領証を保管します。等級はつけず、何も保証しません — 同じコードがあなたの環境でビルドされるかは測定していません。
合格した契約受領証を提出した異なる署名鍵の数です。1 なら作者だけ、2 以上なら他の誰かもビルドしています。鍵は自己生成で背後に登録された身元がないため、数えているのは人ではなく鍵です。
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-01 |
ケース
HOW- ゴール
- verify iniconfig.Section in pkg:pypi/iniconfig@2.3.0
- パッケージ
- シンボル
-
- iniconfig.Section
- 作成日
- 2026-09-01T21:58:06Z
コントラクト
- IniConfig parses INI configuration data and exposes sections as SectionWrapper objects.
- SectionWrapper provides dictionary-like key access and iteration over key-value pairs.
- SectionWrapper.get supports typed conversion callables and default fallback values.
- SectionWrapper.lineof returns source line numbers for options in the section.
ファイル
- PROMPT.md
- csx.json
- requirements.txt
- spec.json
- src/example.py
- test/contract.py
ソース
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 iniconfig.Section in pkg:pypi/iniconfig@2.3.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:pypi/iniconfig@2.3.0
Demonstrate these symbols/APIs:
- iniconfig.Section
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.
{"case":{"caseId":"case:sha256:b8c75fb09febc1629bdbd0e263abe91a8446320bc61808ab62429eb4503c4844","contract":["IniConfig parses INI configuration data and exposes sections as SectionWrapper objects.","SectionWrapper provides dictionary-like key access and iteration over key-value pairs.","SectionWrapper.get supports typed conversion callables and default fallback values.","SectionWrapper.lineof returns source line numbers for options in the section."],"goal":"verify iniconfig.Section in pkg:pypi/iniconfig@2.3.0","kind":"HOW","packages":["pkg:pypi/iniconfig@2.3.0"],"schemaVersion":1,"symbols":["iniconfig.Section"]},"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/iniconfig@2.3.0"],"schemaVersion":1,"subject":"pkg:pypi/iniconfig@2.3.0","symbols":["iniconfig.Section"],"verifierAdapter":"python@1"}
iniconfig==2.3.0
{
"schemaVersion": 1,
"goal": "verify iniconfig.Section in pkg:pypi/iniconfig@2.3.0",
"kind": "HOW",
"packages": [
"pkg:pypi/iniconfig@2.3.0"
],
"symbols": [
"iniconfig.Section"
]
}
"""Demonstration of INI section inspection and data conversion with iniconfig."""
import iniconfig
def parse_and_print_sections(ini_text: str) -> None:
"""Parse INI text and inspect section objects."""
ini = iniconfig.IniConfig("config.ini", ini_text)
for section in ini:
print(f"Section: {section.name}")
for key, value in section.items():
lineno = section.lineof(key)
print(f" line {lineno}: {key} = {value}")
if __name__ == "__main__":
sample_ini = """# Application settings
[web]
host = 127.0.0.1
port = 8080
debug = true
[cache]
enabled = false
ttl = 300
"""
parse_and_print_sections(sample_ini)
"""Contract test for iniconfig.Section in pkg:pypi/iniconfig@2.3.0."""
import sys
import iniconfig
def test_section_wrapper_behavior():
ini_content = """# Service configuration
[service]
host = 127.0.0.1
port = 9000
timeout = 30
debug = true
[database]
engine = sqlite
pool_size = 5
"""
ini = iniconfig.IniConfig("config.ini", ini_content)
# 1. Section retrieval and indexing
assert "service" in ini
assert "database" in ini
assert "missing" not in ini
service_sec = ini["service"]
assert isinstance(service_sec, iniconfig.SectionWrapper)
assert service_sec.name == "service"
assert service_sec.config is ini
# 2. Key access and iteration
assert service_sec["host"] == "127.0.0.1"
assert service_sec["port"] == "9000"
assert list(service_sec) == ["host", "port", "timeout", "debug"]
assert list(service_sec.items()) == [
("host", "127.0.0.1"),
("port", "9000"),
("timeout", "30"),
("debug", "true"),
]
# 3. Typed conversion and default fallbacks via get()
assert service_sec.get("port", convert=int) == 9000
assert service_sec.get("timeout", convert=int) == 30
assert service_sec.get("debug", convert=lambda v: v.strip().lower() == "true") is True
assert service_sec.get("absent_key", default="fallback") == "fallback"
assert service_sec.get("absent_key", default=500, convert=int) == 500
assert service_sec.get("absent_key") is None
# 4. Source line tracking via SectionWrapper.lineof
assert service_sec.lineof("host") == 3
assert service_sec.lineof("port") == 4
assert service_sec.lineof("timeout") == 5
assert service_sec.lineof("debug") == 6
assert service_sec.lineof("nonexistent") is None
# 5. Iteration over IniConfig produces SectionWrapper objects in file order
sections = list(ini)
assert len(sections) == 2
assert [s.name for s in sections] == ["service", "database"]
assert all(isinstance(s, iniconfig.SectionWrapper) for s in sections)
db_sec = ini["database"]
assert db_sec.name == "database"
assert db_sec.get("pool_size", convert=int) == 5
def main():
test_section_wrapper_behavior()
print("CONTRACT PASS: iniconfig.Section verified successfully")
return 0
if __name__ == "__main__":
sys.exit(main())
オリジンシーダー
匿名