Skip to main content

文件树生成工具

Project description

🌳 py-tree - 目录树生成工具

GitHub

一个Python实现的类tree命令工具,支持彩色输出、路径过滤、深度控制等功能,适配中英文环境。


✨ 功能特性

  • 彩色高亮
    区分目录、可执行文件、符号链接等类型(支持自动检测终端颜色)
  • 智能过滤
    • 支持 -P 通配符匹配包含文件
    • 支持 -I 多模式排除文件/目录
    • 支持隐藏文件显示(-a)和仅目录模式(-d
  • 路径显示
    可选完整路径模式(-f)或相对路径
  • 多语言适配
    自动根据系统语言显示中/英文帮助信息
  • 深度控制
    通过 -L 参数限制遍历层级

📦 安装

pip install py-tree

通过入口点命令 ptree 直接调用


🚀 使用示例

基础用法

ptree [目录]

显示隐藏文件(包括.开头文件)

ptree -a ~/projects

限制遍历深度为2

ptree -L 2 /usr

仅显示目录 & 完整路径

ptree -d -f /var/log

组合过滤

# 显示所有test开头的Python文件(排除.log结尾文件)
ptree -P "*.py" -I "*.log" -a src/

📌 命令行选项

usage: ptree [-h] [-a] [-d] [-L LEVEL] [-f] [-I EXCLUDE] [-P PATTERN] [--color {always,auto,never}] [directory]

选项说明:
  -a, --all         显示隐藏文件
  -d, --dir-only    仅显示目录
  -L LEVEL          最大遍历深度
  -f, --full-path   显示完整路径
  -I EXCLUDE        排除模式(可多次使用)
  -P PATTERN        文件名匹配模式
  --color           颜色模式:always/auto/never(默认auto)

🖼️ 效果演示

示例截图
(截图区域建议补充实际效果图)


🤝 贡献指南

欢迎通过Issue报告问题或提交Pull Request!
开发环境建议使用Python 3.8+,遵循PEP8代码规范。


📄 许可证

MIT License

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

stv_pytree-0.0.2.tar.gz (7.1 kB view details)

Uploaded Source

Built Distribution

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

stv_pytree-0.0.2-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

Details for the file stv_pytree-0.0.2.tar.gz.

File metadata

  • Download URL: stv_pytree-0.0.2.tar.gz
  • Upload date:
  • Size: 7.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for stv_pytree-0.0.2.tar.gz
Algorithm Hash digest
SHA256 e61415abf1441e9dcd1218a0fb89ba68eb53f6da8b3ba1e451be8528a5655d9f
MD5 2b130de703f63dd39df246d306e619c7
BLAKE2b-256 fb82958d609f6bc984728ed82e99c4fde5771e2049287a0c04b8dfb2a41e5e26

See more details on using hashes here.

File details

Details for the file stv_pytree-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: stv_pytree-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 7.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for stv_pytree-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 96e0eba040d1fce5c2dbcb142b44c68bcd8c629e6ef6b314c3f9cba747b652bc
MD5 5a67570d8cf383771abe3268f2de7d4d
BLAKE2b-256 99b173c5116b169735b1798ac3c648dad24dc9f56aa5142135076f13933146e4

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