|
| 1 | +# Python Utils |
| 2 | + |
| 3 | +- [Simplified Chinese](README.md) |
| 4 | +- [English](README.en.md) |
| 5 | + |
| 6 | +让开发和生活都更快乐的小工具集合 🧰 |
| 7 | + |
| 8 | +## 📦 Tool list |
| 9 | + |
| 10 | +| module | describe | main document | |
| 11 | +| ----------------- | ------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | |
| 12 | +| **cli_logger** | Loguru log configuration example, console + file dual-channel output | [`cli_logger.py`](cli_logger/cli_logger.py) | |
| 13 | +| **dirwatch** | Real-time monitoring of folder changes (add/delete/modify/rename) | [`dirwatch.py`](dirwatch/dirwatch.py) | |
| 14 | +| **format_cmake** | Format CMake files (single or recursive directories) | [`format_cmake.py`](format_cmake/format_cmake.py) | |
| 15 | +| **hash** | Calculate the hash value of a file or text (MD5/SHA-1/SHA-2/SHA-3/BLAKE2/BLAKE3) | [`hash.py`](hash/hash.py) | |
| 16 | +| **image-toolkit** | Image format conversion tool + one-click generation/analysis`.icns`/`.ico` | [`convert_img.py`](image-toolkit/convert_img.py)/[`dump_icns.py`](image-toolkit/dump_icns.py)/[`dump_ico.py`](image-toolkit/dump_ico.py)/[`make_icns.py`](image-toolkit/make_icns.py)/[`make_ico.py`](image-toolkit/make_ico.py) | |
| 17 | +| **m3u8_download** | m3u8 downloader, automatically merge ts into a single video | [`m3u8_dl.py`](m3u8_download/m3u8_dl.py) | |
| 18 | +| **procmon** | Real-time monitoring of CPU/memory/threads/handles by process name | [`procmon.py`](procmon/procmon.py) | |
| 19 | +| **resolve** | 域名解析工具,快速获取 IP、端口、协议信息 | [`resolve.py`](resolve/resolve.py) | |
| 20 | +| **tree** | Visual directory tree generation tool | [`tree.py`](tree/tree.py) | |
| 21 | +| **utils** | General tool library (color output, etc.) | [`colors.py`](utils/colors.py) | |
| 22 | +| **sync_req** | Depend on the synchronization tool and generate requirements.txt from pyproject.toml | [`sync_req.py`](sync_req.py) | |
| 23 | + |
| 24 | +## 🚀 Quick start |
| 25 | + |
| 26 | +### Install uv |
| 27 | + |
| 28 | +First you need to install uv - the extremely fast Python package manager and project tool chain: |
| 29 | + |
| 30 | +**Install using pip (cross-platform):** |
| 31 | + |
| 32 | +```bash |
| 33 | +pip install uv -i https://pypi.tuna.tsinghua.edu.cn/simple |
| 34 | +``` |
| 35 | + |
| 36 | +**Verify installation:** |
| 37 | + |
| 38 | +```bash |
| 39 | +uv --version |
| 40 | +``` |
| 41 | + |
| 42 | +### Install project dependencies |
| 43 | + |
| 44 | +Use uv to manage project dependencies: |
| 45 | + |
| 46 | +```bash |
| 47 | +# 使用 uv 创建虚拟环境并安装所有依赖(一步完成) |
| 48 | +uv sync --dev |
| 49 | + |
| 50 | +# 或者分步执行: |
| 51 | +# 1. 创建虚拟环境(默认在 .venv 目录) |
| 52 | +uv venv |
| 53 | + |
| 54 | +# 2. 激活虚拟环境 (Linux/macOS) |
| 55 | +source .venv/bin/activate |
| 56 | + |
| 57 | +# 3. 安装项目依赖(可编辑模式) |
| 58 | +uv pip install -e . |
| 59 | +``` |
| 60 | + |
| 61 | +### Synchronize dependency files |
| 62 | + |
| 63 | +The project provides`sync_req.py`Tools for starting from`pyproject.toml`generate`requirements.txt`: |
| 64 | + |
| 65 | +```bash |
| 66 | +# 生成 requirements.txt |
| 67 | +python sync_req.py |
| 68 | + |
| 69 | +# 使用 uv 通过 requirements.txt 安装依赖 |
| 70 | +uv pip install -r requirements.txt |
| 71 | +``` |
| 72 | + |
| 73 | +### Use Tsinghua image acceleration (optional) |
| 74 | + |
| 75 | +如果需要使用国内镜像源: |
| 76 | + |
| 77 | +```bash |
| 78 | +# 设置环境变量使用清华镜像 |
| 79 | +export UV_INDEX_URL=https://pypi.tuna.tsinghua.edu.cn/simple |
| 80 | +uv sync --dev |
| 81 | + |
| 82 | +# 或者单次命令指定镜像 |
| 83 | +uv pip install -e . -i https://pypi.tuna.tsinghua.edu.cn/simple |
| 84 | +``` |
| 85 | + |
| 86 | +### Instructions for use |
| 87 | + |
| 88 | +👉 Direct`cd`Enter the corresponding directory,`uv run python xxx.py -h`Check out the specific usage! |
0 commit comments