Skip to main content

终端彩色工具 + 安全密钥生成

Project description

text_discoloration

Colorful terminal output with typewriter effect. Zero dependencies.

Features

Color Output

  • 8 classic colors: Red, Green, Yellow, Blue, Purple, Cyan, White, Black
  • Direct color printing: color_print_red("Hello")
  • Color typewriter effect: typewriter_blue("Hello", delay=0.05)

Typewriter Effects

  • Standard typewriter: typewriter("text", delay=0.05)
  • Random color typewriter: random_typewriter("rainbow text")
  • Custom color typewriter: color_typewriter("text", "green")

Status Prompts

  • info("Loading...") → Blue [INFO]
  • success("Done!") → Green [SUCCESS]
  • error("Failed") → Red [ERROR]
  • warn("Check this") → Yellow [WARNING]

Utilities

  • slow_print("slow text", delay=0.05) — Print character by character
  • color_print_red("text") — Print without typewriter effect

Installation

pip install text_discoloration

Update Notice

  • Log prompt is disabled by default.
  • If you need to enable log prompts, use the example below:
from text_discoloration import set_verbose
set_verbose()

更新日志

Changelog

[3.2.0] - 2026-05-23

Added

  • 新增 download_file() 下载文件功能
    • 支持进度条显示
    • 支持自定义请求头(伪装)
    • 支持重试机制(默认2次)
    • 支持断点续传(自动处理)
    • 提供友好的错误提示和建议
  • 新增 get_downloads() 查询 PyPI 模块下载量
    • 支持缓存(60秒内重复查询返回缓存结果)
    • 支持重试机制
  • 新增 ra 命令行密钥生成工具
    • 支持 ra -i 32 指定长度
    • 支持 ra 1 -i 32 关闭数字
    • 支持 ra 2 关闭小写、ra 3 关闭大写、ra 4 关闭符号
  • 新增文件管理 CLI 命令
    • tcd file read <file> 读取文件
    • tcd file write <file> <content> 写入文件
    • tcd file append <file> <content> 追加内容
    • tcd file edit <file> 交互式编辑
    • tcd file hash <file> 计算哈希
    • tcd file b64 <file> Base64 编码文件
  • 新增 tcd downloads <模块名> 查询单个模块下载量
  • 新增 tcd downloads-all 批量查询预设模块下载量
  • 新增 dataclass 序列化支持
    • to_json(obj) dataclass → JSON 字符串
    • from_json(cls, json_str) JSON 字符串 → dataclass
    • to_dict(obj) dataclass → 字典
    • from_dict(cls, data) 字典 → dataclass
    • 支持嵌套 dataclass、datetime、date、Enum、list 等类型

Changed

  • ra_key() 函数现支持 no_lowerno_upper 参数(单独控制大小写)
  • CLI 命令统一整合,tcdra 共享同一个入口
  • 下载进度条优化,增加实时速度显示
  • 文件管理功能增强,支持更多操作

Fixed

  • 修复 ra 命令在重构后丢失的问题(现已恢复)
  • 修复下载时偶发的 socket.timeout 未捕获异常
  • 修复 download_file 中重复导入 time 的问题
  • 修复 setup.pyentry_points 指向错误的问题

Security

  • 下载功能默认添加 User-Agent 伪装,避免被部分服务器拒绝
  • 网络错误时提供清晰的解决建议(DNS、超时、权限等)

[3.1.0] - 2026-05-22

Added

  • 新增 disable_log() 关闭内部日志输出
  • 新增 enable_log() 开启内部日志输出
  • 新增 _print_error() / _print_warn() 用户可见错误提示
  • 新增 scan_text_file() 对非 Python 文件的安全扫描
  • 新增计划(plan)配置管理支持
  • 新增 skip_incomplete 配置项,允许语法错误只警告不拦截

Changed

  • 日志系统重构:_log_enabled 控制内部日志,_quiet 控制用户输出
  • static_scan 函数优化:语法错误只警告,不直接拦截
  • separator() 在静默模式下输出普通分隔线
  • progress_bar() 在静默模式下输出百分比
  • edit_file() 在静默模式下限制输出行数(最多50行)
  • spinnerspinner_context 合并为工厂函数 _create_spinner

Fixed

  • 修复 text_discoloration 在 Termux 环境下的兼容性问题
  • 修复静默模式下 table() 忽略 headers 的问题
  • 修复 binary_textglobals() 查找颜色函数的问题
  • 修复 ra_key 未导出到 __all__ 的问题

[3.0.0] - 2026-05-20

Added

  • 初始稳定版本
  • 彩色终端输出
  • 打字机特效
  • 状态提示(info/success/error/warn)
  • 进度条、表格、树形结构
  • 文件读写、哈希计算
  • Base64 编解码
  • 二进制执行(安全沙箱模式)
  • 日志记录器(Logger)

[2.0.0] - 2026-05-10

Added

  • 早期版本,基础功能

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

text_discoloration-3.2.0.tar.gz (19.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

text_discoloration-3.2.0-py3-none-any.whl (19.6 kB view details)

Uploaded Python 3

File details

Details for the file text_discoloration-3.2.0.tar.gz.

File metadata

  • Download URL: text_discoloration-3.2.0.tar.gz
  • Upload date:
  • Size: 19.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.13

File hashes

Hashes for text_discoloration-3.2.0.tar.gz
Algorithm Hash digest
SHA256 f555604de9379364afc0b7129a0d7fefcee304376640f27086c9411f8ff5e44c
MD5 55f04770af44fc005a77cb98f01be218
BLAKE2b-256 8c989a28fd6ec030f7c8cb9f0e289213bf9f30a58b2716065742c28d1c86e342

See more details on using hashes here.

File details

Details for the file text_discoloration-3.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for text_discoloration-3.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 35c5db2f098b0015d67b3e740eea5741feba6dd1bfad9337950f924ba3b60330
MD5 e9b19d17c9895cef4f83c9d6fb385ba0
BLAKE2b-256 bcafbd60b741656147814f2618dfd3684f5c41af61b814c01c272ed010afc7bc

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page