Skip to main content

pewutils

PE Windmill Utils —— 为 Windmill 脚本平台提供的轻量级 Python 工具包。

由 peutils 迁移重构而来,适配 windmill 脚本平台。

已迁移模块

模块 说明 依赖
url_util URL 处理工具(解析、存储 URL、签名 URL 清理、查询参数等) 仅标准库
oss_util 阿里云 OSS 工具(STS 鉴权、列举、复制、搜索) oss2, requests
wmill_util Windmill 平台工具(zip 打包上传 S3) wmill(windmill runtime 内置)

安装

# 核心包(含 oss2/requests 依赖)
pip install pewutils

# 本地开发(editable)
git clone <repo-url> pewutils
cd pewutils
pip install -e .

使用示例

URL 工具

from pewutils.url_util import (
    get_clean_url,
    parse_storage_url,
    parse_oss_full_path,
    get_relative_path,
)

# 去除 OSS 签名 URL 的查询参数
clean = get_clean_url("https://bucket.aliyuncs.com/path/file.pcd?Expires=123&Signature=xxx")
# -> "https://bucket.aliyuncs.com/path/file.pcd"

# 解析存储 URL(宽松)
bucket, path = parse_storage_url("oss://my-bucket/folder/file.txt")
# -> ("my-bucket", "folder/file.txt")

# 解析 OSS 目录路径(强约束,要求以 / 结尾)
bucket, folder = parse_oss_full_path("oss://my-bucket/folder/")

OSS 工具

from pewutils.oss_util import OSSClientFactory

# 创建带自动刷新的 OSS client(auth_str 12h 过期,11h 自动刷新)
client = OSSClientFactory.create_client(bucket_name="my-bucket")

# 读取 OSS 对象为字节流
data = client.read_bytes("path/to/file.pcd")

# 列举目录下所有文件
files = client.list_bucket_files_deep("path/to/folder/")

# BFS 查找最浅的目标文件
path = client.find_shallowest_target("root/", "target.json", "file")

Windmill 平台工具

from pewutils.wmill_util import zip_to_s3

# with 块内生成文件,退出时自动打包 zip 上传到 Windmill S3
with zip_to_s3("output/zip", suffix=".json") as out:
    Path("a.json").write_text('{"k": 1}')
    Path("b.json").write_text('{"k": 2}')
# out.result -> S3Object(s3="output/zip/20260729/uuid.zip")
# out.files  -> [Path("a.json"), Path("b.json")]

目录结构

pewutils/
├── README.md
├── pyproject.toml              # 打包配置(PEP 517/518,requires-python>=3.10)
├── .gitignore
└── pewutils/
    ├── __init__.py             # 默认导出 url_util
    ├── url_util.py             # URL 处理(纯标准库)
    ├── oss_util.py             # OSS 工具(oss2, requests)
    └── wmill_util.py           # Windmill 平台工具(wmill lazy import)

构建

pip install build
python -m build
# 产物:dist/pewutils-<version>-py3-none-any.whl

Metadata

Release files for pewutils 0.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pewutils 0.0.3
File Size Uploaded Provenance Actions
pewutils-0.0.3.tar.gz 18.9 kB Without provenance Details for pewutils-0.0.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pewutils 0.0.3
File Interpreter ABI Platform Actions
pewutils-0.0.3-py3-none-any.whl Python 3 none any Details for pewutils-0.0.3-py3-none-any.whl

Total release size: 39.5 kB

Release files / pewutils-0.0.3.tar.gz

Download URL pewutils-0.0.3.tar.gz
Size 18.9 kB
Tags Source
SHA-256 checksum
How to use checksums
88140d50c29ed4c13b722b758c902d65f988a0d6c17c73a220e5b5ee85b4da91
BLAKE2b-256 checksum
How to use checksums
a83f30590b0e5ed3bc3e5bfd7da11d37731c72f3cf0354ed594f4ab0ec9344d5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.5

Release files / pewutils-0.0.3-py3-none-any.whl

Download URL pewutils-0.0.3-py3-none-any.whl
Size 20.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e261e6509330e6c348f2ab0e26dd739ef35f02c155f90c63ed99572ce80a7777
BLAKE2b-256 checksum
How to use checksums
9bc6a7ab5829b360f4499f2d8d71d0a6fa0e989ac9091a90c5c368e6dca973a3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.5

Security for pewutils 0.0.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page