A small collection of practical Python command line tools.
The repository is intentionally simple: each tool is small enough to read in a few minutes, has focused tests, and can be used directly from the command line.
这是一个轻量的 Python 命令行工具集合。每个工具都尽量保持小而清晰, 方便直接阅读源码、运行测试,并在日常任务中通过命令行使用。
安装开发环境:
python -m pip install -e ".[test]"Format JSON from a file or from standard input.
从文件或标准输入读取 JSON,并输出格式化或压缩后的结果。
json-format --file payload.json
python -m daily_tools.json_format --minify --sort-keys < payload.jsonExtract selected columns from a CSV file or from standard input.
从 CSV 文件或标准输入中提取指定列,并保持原有行顺序。
csv-select name email --file contacts.csv
python -m daily_tools.csv_select city country --file addresses.csv --delimiter ";"
python -m daily_tools.csv_select 3 1 --by-index --no-header --file rows.csv
python -m daily_tools.csv_select name city --file contacts.csv --output selected.csvCalculate file or stdin digests with standard-library hash algorithms.
使用 Python 标准库支持的哈希算法计算文件或标准输入的摘要。
file-hash README.md
python -m daily_tools.file_hash --algorithm md5 README.md TOOL_INDEX.mdCreate an anonymized copy of a course-material directory before publishing it.
为课程资料目录生成脱敏副本,适合在公开发布前替换姓名、学号等个人信息。 源目录不会被修改。
python -m course_anonymizer sanitize "path/to/course" --config course-anonymizer/privacy-map.example.json --output "path/to/sanitized-course" --report privacy_report.jsonScan a course-material directory or create a cleaned copy without generated files, build outputs, dependency folders, IDE metadata, and large files.
扫描课程资料目录,或生成清理后的副本,跳过编译产物、依赖目录、IDE 元数据和 过大的文件。源目录不会被修改。
python -m course_clean scan "path/to/course" --report cleanup_report.json
python -m course_clean copy "path/to/course" --output "path/to/cleaned-course" --report cleanup_report.jsonRecursively convert Word documents to PDFs while preserving relative directory paths. The output directory contains only generated PDFs, and the source files are not modified.
递归把课程目录中的 Word 文档转换为 PDF,并保留相对目录结构。输出目录只包含 生成的 PDF,源文件不会被修改。
python -m word_to_pdf convert "path/to/course" --output "path/to/course-pdfs" --report conversion_report.jsonSummarize text from one or more files, or from standard input.
统计一个或多个文本文件,或标准输入中的字符数、词数、行数、句子数和段落数。
text-stats README.md
python -m daily_tools.text_stats --json README.mdRun the test suite before committing changes:
提交修改前请运行测试:
python -m pytest