샘플
colorama 0.4.6: colorize terminal text with Fore, Back, and Style and manage ANSI formatting lifecycle
검증된 샘플 — pypi colorama 0.4.6: colorize terminal text with Fore, Back, and Style and manage ANSI formatting lifecycle. python 3.12 · linux alpine/x64 …
sha256:7934af40d2b4ebc58157550a5b3c5de866abdd7e07ce40a9ca9b38d6f16757ab
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
MIT-0
실행 증거
선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.
- 증거 기준
- 서명된 컨트랙트 통과
- 검증 영수증
- 1
- 빌드한 서명 키
- 1
선언된 환경
python 3.12 linux 24 · ubuntu · glibc 2.39 x64 python 3.12 python uv
검증 실행 환경
| 환경 | 컨트랙트 | 단계 | 실행일 |
|---|---|---|---|
| python 3.12 · linux alpine/x64 · docker ed25519:d91480838ac982c9 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · python@1python:3.12-alpine@sha256:d09d15e60962… |
2026-08-23 |
케이스
HOW- 목표
- colorize terminal text with Fore, Back, and Style and manage ANSI formatting lifecycle
- 패키지
- 환경
- python 3.12
- 생성일
- 2026-08-23T16:03:57Z
컨트랙트
- colorama.Fore provides ANSI color escape sequences including Fore.RED, Fore.GREEN, Fore.BLUE, and Fore.RESET
- colorama.Back provides ANSI background escape sequences including Back.GREEN, Back.RED, and Back.RESET
- colorama.Style provides text style escape sequences including Style.BRIGHT, Style.DIM, Style.NORMAL, and Style.RESET_ALL
- colorama.Cursor provides parameterized terminal cursor positioning escape codes including UP, DOWN, FORWARD, BACK, and POS
- colorama.ansi.code_to_chars converts integer ANSI control codes to escape sequence strings
- colorama.ansitowin32.AnsiToWin32 wraps streams with autoreset to append Style.RESET_ALL after writes
- colorama.init, colorama.deinit, and colorama.reinit manage wrapping and restoring standard output streams
파일
- PROMPT.md
- csx.json
- pyproject.toml
- requirements.txt
- spec.json
- test/contract.py
- uv.lock
소스
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: colorize terminal text with Fore, Back, and Style and manage ANSI formatting lifecycle
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:pypi/colorama@0.4.6
Constraints:
- executionContext: node
Required runtime conditions:
- ecosystem: npm
- language: javascript
- moduleSystem: cjs
- packageManager: npm@10.9.8
- runtime: node@22.23.2
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:07c94a13005cf2d465cbfb324841a12eea93d1022b4a053cec0a1ebab2e275ad","contract":["colorama.Fore provides ANSI color escape sequences including Fore.RED, Fore.GREEN, Fore.BLUE, and Fore.RESET","colorama.Back provides ANSI background escape sequences including Back.GREEN, Back.RED, and Back.RESET","colorama.Style provides text style escape sequences including Style.BRIGHT, Style.DIM, Style.NORMAL, and Style.RESET_ALL","colorama.Cursor provides parameterized terminal cursor positioning escape codes including UP, DOWN, FORWARD, BACK, and POS","colorama.ansi.code_to_chars converts integer ANSI control codes to escape sequence strings","colorama.ansitowin32.AnsiToWin32 wraps streams with autoreset to append Style.RESET_ALL after writes","colorama.init, colorama.deinit, and colorama.reinit manage wrapping and restoring standard output streams"],"goal":"colorize terminal text with Fore, Back, and Style and manage ANSI formatting lifecycle","kind":"HOW","packages":["pkg:pypi/colorama@0.4.6"],"schemaVersion":1},"contractCommand":["python3","test/contract.py"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"pypi","language":"python","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"uv","runtime":"python","runtimeVersion":"3.12","schemaVersion":1},"license":"MIT-0","packages":["pkg:pypi/colorama@0.4.6"],"schemaVersion":1,"subject":"pkg:pypi/colorama@0.4.6","verifierAdapter":"python@1"}
[project]
name = "sample-colorama"
version = "0.1.0"
requires-python = ">=3.8"
dependencies = [
"colorama==0.4.6",
]
colorama==0.4.6
{
"schemaVersion": 1,
"goal": "colorize terminal text with Fore, Back, and Style and manage ANSI formatting lifecycle",
"kind": "HOW",
"packages": [
"pkg:pypi/colorama@0.4.6"
],
"constraints": {
"executionContext": "node"
},
"runtimeConditions": {
"ecosystem": "npm",
"language": "javascript",
"moduleSystem": "cjs",
"packageManager": "npm@10.9.8",
"runtime": "node@22.23.2"
}
}
import io
import sys
import colorama
from colorama import Fore, Back, Style, Cursor, ansi
from colorama.ansitowin32 import AnsiToWin32
def test_fore_colors():
assert Fore.RED == "\033[31m", f"Fore.RED mismatch: {repr(Fore.RED)}"
assert Fore.GREEN == "\033[32m", f"Fore.GREEN mismatch: {repr(Fore.GREEN)}"
assert Fore.BLUE == "\033[34m", f"Fore.BLUE mismatch: {repr(Fore.BLUE)}"
assert Fore.RESET == "\033[39m", f"Fore.RESET mismatch: {repr(Fore.RESET)}"
def test_back_colors():
assert Back.RED == "\033[41m", f"Back.RED mismatch: {repr(Back.RED)}"
assert Back.GREEN == "\033[42m", f"Back.GREEN mismatch: {repr(Back.GREEN)}"
assert Back.RESET == "\033[49m", f"Back.RESET mismatch: {repr(Back.RESET)}"
def test_styles():
assert Style.BRIGHT == "\033[1m", f"Style.BRIGHT mismatch: {repr(Style.BRIGHT)}"
assert Style.DIM == "\033[2m", f"Style.DIM mismatch: {repr(Style.DIM)}"
assert Style.NORMAL == "\033[22m", f"Style.NORMAL mismatch: {repr(Style.NORMAL)}"
assert Style.RESET_ALL == "\033[0m", f"Style.RESET_ALL mismatch: {repr(Style.RESET_ALL)}"
def test_cursor():
assert Cursor.UP(3) == "\033[3A", f"Cursor.UP mismatch: {repr(Cursor.UP(3))}"
assert Cursor.DOWN(2) == "\033[2B", f"Cursor.DOWN mismatch: {repr(Cursor.DOWN(2))}"
assert Cursor.FORWARD(4) == "\033[4C", f"Cursor.FORWARD mismatch: {repr(Cursor.FORWARD(4))}"
assert Cursor.BACK(1) == "\033[1D", f"Cursor.BACK mismatch: {repr(Cursor.BACK(1))}"
assert Cursor.POS(10, 5) == "\033[5;10H", f"Cursor.POS mismatch: {repr(Cursor.POS(10, 5))}"
def test_code_to_chars():
assert ansi.code_to_chars(31) == "\033[31m", f"code_to_chars(31) mismatch: {repr(ansi.code_to_chars(31))}"
assert ansi.code_to_chars(42) == "\033[42m", f"code_to_chars(42) mismatch: {repr(ansi.code_to_chars(42))}"
assert ansi.code_to_chars(0) == "\033[0m", f"code_to_chars(0) mismatch: {repr(ansi.code_to_chars(0))}"
def test_ansitowin32_autoreset():
buf = io.StringIO()
wrapper = AnsiToWin32(buf, autoreset=True, convert=False, strip=False)
wrapper.write(Fore.GREEN + "success")
assert buf.getvalue() == Fore.GREEN + "success" + Style.RESET_ALL, f"autoreset mismatch: {repr(buf.getvalue())}"
def test_lifecycle():
orig_stdout = sys.stdout
orig_stderr = sys.stderr
try:
colorama.init(autoreset=False)
assert sys.stdout is not None, "sys.stdout is None after colorama.init()"
colorama.deinit()
assert sys.stdout is orig_stdout, "deinit did not restore original stdout"
assert sys.stderr is orig_stderr, "deinit did not restore original stderr"
colorama.reinit()
assert sys.stdout is not None, "sys.stdout is None after colorama.reinit()"
finally:
colorama.deinit()
assert sys.stdout is orig_stdout, "final deinit did not restore stdout"
def main():
test_fore_colors()
test_back_colors()
test_styles()
test_cursor()
test_code_to_chars()
test_ansitowin32_autoreset()
test_lifecycle()
print("All contract assertions passed.")
if __name__ == "__main__":
main()
version = 1
revision = 3
requires-python = ">=3.8"
[[package]]
name = "colorama"
version = "0.4.6"
source = { registry = "https://pypi.org/simple" }
sdist = { url = "https://files.pythonhosted.org/packages/d8/53/6f443c9a4a8358a93a6792e2acffb9d9d5cb0a5cfd8802644b7b1c9a02e4/colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44", size = 27697, upload-time = "2022-10-25T02:36:22.414Z" }
wheels = [
{ url = "https://files.pythonhosted.org/packages/d1/d6/3965ed04c63042e047cb6a3e6ed1a63a35087b6a609aa3a15ed8ac56c221/colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6", size = 25335, upload-time = "2022-10-25T02:36:20.889Z" },
]
[package.metadata]
requires-dist = [{ name = "colorama", specifier = "==0.4.6" }]
오리진 시더
익명