A collection of automation tools for Python projects
Project description
zyt_auto_tools
zyt_auto_tools 是一个 Python 工具集,旨在帮助开发者自动化常见的项目任务。它包含以下工具:
- 自动生成
__init__.py文件:根据指定目录下的指定部分文件,自动生成__init__.py文件。 - 自动创建 Python 文件:快速生成带有标准模板的 Python 文件。
- 自动更新文件修改时间:更新项目中今天修改过的
.py文件的Update日期。 - 自动生成项目结构图:生成项目的目录结构图,支持文本和
.gitignore规则。 - 自动创建 Python 项目文件夹:快速生成指定类型的 Python 项目架构文件夹。
📌 当前版本:
v0.4.1| 🆕 查看更新日志 »
安装
你可以通过 pip 安装这个工具集:
pip install zyt-auto-tools
使用方法
1. 自动生成 __init__.py 文件
在项目根目录下运行以下命令,自动生成指定目录下的 __init__.py 文件(默认utils下全部文件):
auto-generate-init
① 你还可以通过 '-d' 或 '--dir' 指定目标目录(默认utils):
auto-generate-init --dir ./my_project
② 你还可以通过 '-i' 或 '--include' 指定所包含的文件名(默认选择包含以.py结尾的文件):
# 例如选择文件名中含有xxx的文件
auto-generate-init --include *xxx*
③ 你还可以通过 '-t' 或 '--type' 来选择生成的内容(public:非_开头的顶层类和函数;all:全部顶层类和函数;star:通配导入,默认public):
auto-generate-init --type public
or
auto-generate-init --type all
or
auto-generate-init --type star
④ 你还可以通过 '-a' 或 '--author' 指定作者:
auto-generate-init --author your_name
作者名可以通过环境变量 DEFAULT_AUTHOR 设置:
# Linux
export DEFAULT_AUTHOR=your_name
or
# Windows
$env:DEFAULT_AUTHOR = "your_name"
2. 自动创建 Python 文件
使用以下命令快速创建一个带有标准模板的 Python 文件(默认在项目根目录下,默认本作者):
auto-init-python-file my_script.py
① 你还可以通过 '-d' 或 '--dir' 指定目标目录:
auto-init-python-file my_script.py --dir ./my_project
② 你还可以通过 '-a' 或 '--author' 指定作者:
auto-init-python-file my_script.py --author your_name
作者名可以通过环境变量 DEFAULT_AUTHOR 设置:
# Linux
export DEFAULT_AUTHOR=your_name
or
# Windows
$env:DEFAULT_AUTHOR = "your_name"
3. 自动更新文件修改时间
在项目根目录下运行以下命令,更新全部根目录下今天修改过的 .py 文件的 Update 日期:
auto-update-ctime
① 你还可以通过 '-d' 或 '--dir' 指定目标目录:
auto-update-ctime --dir ./my_project
4. 自动生成项目结构图
在项目根目录下运行以下命令,生成项目的目录结构图(默认输出到控制台):
auto-create-structure
① 你还可以通过 '-d' 或 '--dir' 指定目标目录:
auto-create-structure --dir ./my_project
② 你还可以通过 -o 或 --output 指定输出文件路径:
auto-create-structure --output project_structure.txt
③ 你还可以通过 -i 或 --ignore 指定额外忽略的目录/文件(支持通配符):
auto-create-structure --ignore *.log tests/
④ 你还可以通过 --use-gitignore 使用 .gitignore 文件中的规则替换默认忽略列表:
auto-create-structure --use-gitignore
5. 自动创建 Python 项目文件夹
使用以下命令快速创建指定类型的 Python 项目文件夹(默认在项目根目录下,默认本作者, 默认类型为标准的python文件夹):
auto-init-python-dir
① 你还可以通过 '-t' 或 '--type' 指定项目类型(支持None, software, crawler, spiders):
auto-init-python-dir --type software
② 你还可以通过 '-d' 或 '--dir' 指定目标目录:
auto-init-python-dir --dir ./my_project
③ 你还可以通过 '-a' 或 '--author' 指定作者:
auto-init-python-dir --author your_name
作者名可以通过环境变量 DEFAULT_AUTHOR 设置:
# Linux
export DEFAULT_AUTHOR=your_name
or
# Windows
$env:DEFAULT_AUTHOR = "your_name"
更新日志
V0.4.1
2025-07-07
⚙️ 功能优化
1. auto-init-python-dir 命令
- ①优化生成crawler项目初始化内容:
- 新增
plugins文件夹(启动器扩展功能模块),移动原proxy_test.py - 新增
utils文件夹(通用函数与log记录函数),移动原utils.py - 新增
settings文件夹(配置文件夹),移动原lake文件夹 - 新增
logger.py(日志配置) - 新增
start_crawler.py(爬虫系统启动代码) - 优化
config.py - 优化
spiders/example.py
- 新增
- ②优化生成software项目初始化内容:
- 优化
network/server_connect.py函数导入顺序
- 优化
2. auto-generate_init 命令
- ①优化导入内容生成,现在会只包含顶层的类与函数
- ②优化type参数,新增选择是否导入以
_开头的顶层类或函数 - ③优化type参数名:
- public:非_开头的顶层类和函数(默认参数)
- all:全部顶层类和函数
- star:通配导入
📜 完整更新日志
点此查看所有历史版本和详细改动说明:
🔗查看完整更新日志 »
贡献
欢迎贡献代码!
许可证
本项目基于 MIT 许可证 开源。
作者
- ZhangYuetao - 项目开发者
- 邮箱: zhang894171707@gmail.com
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file zyt_auto_tools-0.4.1.tar.gz.
File metadata
- Download URL: zyt_auto_tools-0.4.1.tar.gz
- Upload date:
- Size: 14.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
201b90e4dd71dfa61a5c50225cadaa8fde4b683b8b81d9af1696c45348e39874
|
|
| MD5 |
3b42d92ab591ed643f22e286fbdf1760
|
|
| BLAKE2b-256 |
a8e3bc3b3bb643ede237e6c2bc99c7a83fa151ed980aa1f075269b6d31ef82d6
|
File details
Details for the file zyt_auto_tools-0.4.1-py3-none-any.whl.
File metadata
- Download URL: zyt_auto_tools-0.4.1-py3-none-any.whl
- Upload date:
- Size: 212.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
395ad869d543de9992c16fe5d7e76fea0889726552a913b1996be9edfb2c9483
|
|
| MD5 |
83085c644283507f21961562e4f42dc8
|
|
| BLAKE2b-256 |
9873ebf54715dfe043e7b53e0a0d548abe104998abbd9f5f0504a32b5ea3377d
|