Add your description here
Project description
OmniPath
OmniPath 是一个统一的路径处理库,支持本地文件系统、HTTP 和 S3 存储的路径操作。它提供了同步和异步 API,使得在不同存储系统间操作文件变得简单统一。
安装
pip install omni_pathlib
基本用法
from omni_pathlib import OmniPath
# 创建不同类型的路径
http_path = OmniPath("https://example.com/file.txt")
s3_path = OmniPath("s3://my-bucket/path/to/file.txt")
local_path = OmniPath("/local/path/to/file.txt")
# 读取文件内容
content = http_path.read_text() # 从 HTTP 读取
s3_content = s3_path.read_text() # 从 S3 读取
local_content = local_path.read_text() # 从本地读取
# 异步操作
async def main():
content = await http_path.async_read_text()
s3_content = await s3_path.async_read_text()
local_content = await local_path.async_read_text()
特性
- 统一的路径操作接口
- 支持本地文件系统、HTTP 和 S3 存储
- 同步和异步 API
- HTTP 支持缓存和断点续传
- S3 支持完整的存储桶操作
- 本地文件系统支持标准的路径操作
函数接口说明
基础操作
exists()/async_exists()- 检查路径是否存在iterdir()/async_iterdir()- 遍历目录内容stat()/async_stat()- 获取文件信息(大小、修改时间等)read_bytes()/async_read_bytes()- 读取文件内容(二进制)read_text()/async_read_text()- 读取文件内容(文本)write_bytes(data)/async_write_bytes(data)- 写入文件内容(二进制)write_text(data)/async_write_text(data)- 写入文件内容(文本)delete()/async_delete()- 删除文件
本地文件系统特有操作
mkdir(parents=False, exist_ok=False)/async_mkdir()- 创建目录rmdir()/async_rmdir()- 删除空目录rename(target)/async_rename(target)- 重命名文件/目录is_dir()/async_is_dir()- 检查是否为目录is_file()/async_is_file()- 检查是否为文件
HTTP 特有功能
- 支持断点续传
- 自动缓存下载内容
- 不支持写入和删除操作
S3 特有功能
- 完整支持 S3 存储桶操作
- 支持自定义 endpoint
- 支持多种认证方式
S3 鉴权信息获取逻辑
- 从环境变量
AWS_ACCESS_KEY_ID,AWS_SECRET_ACCESS_KEY,AWS_REGION,OSS_ENDPOINT,S3_ENDPOINT,AWS_ENDPOINT_URL获取环境变量配置 - 从环境变量
AWS_SHARED_CREDENTIALS_FILE获取配置文件路径并加载配置,默认~/.aws/credentials - 环境变量配置优先级高于配置文件配置
- 从环境变量
AWS_PROFILE获取 profile 名称,默认default - 若 profile 名称对应的配置不存在,则使用第一个配置名称
开发
安装依赖
uv sync
运行测试
uv run pytest
commit
cz commit
发布
cz release
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 omni_pathlib-0.1.1.tar.gz.
File metadata
- Download URL: omni_pathlib-0.1.1.tar.gz
- Upload date:
- Size: 124.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8b97e2eab991e4d94df6236c520337430ad09e17e390fc727e6c58efe20f7e6b
|
|
| MD5 |
99a8839842bbe679dce5e08a82b36daa
|
|
| BLAKE2b-256 |
cd562519fd26966c13ed23998382b4c0379d6d6a7cf143cafc296b2ee55cbfb8
|
Provenance
The following attestation bundles were made for omni_pathlib-0.1.1.tar.gz:
Publisher:
publish-to-pypi.yml on Haskely/omni-pathlib
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
omni_pathlib-0.1.1.tar.gz -
Subject digest:
8b97e2eab991e4d94df6236c520337430ad09e17e390fc727e6c58efe20f7e6b - Sigstore transparency entry: 162938420
- Sigstore integration time:
-
Permalink:
Haskely/omni-pathlib@e21331049d4f5b8f88dbe846a62e35285cf28974 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/Haskely
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@e21331049d4f5b8f88dbe846a62e35285cf28974 -
Trigger Event:
push
-
Statement type:
File details
Details for the file omni_pathlib-0.1.1-py3-none-any.whl.
File metadata
- Download URL: omni_pathlib-0.1.1-py3-none-any.whl
- Upload date:
- Size: 22.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
83b2f87608abb2e32094b46d9355663cbf9fc7c203a8c82f41a9471f9fceca69
|
|
| MD5 |
a456c1b7998a4e86c9829379b226196d
|
|
| BLAKE2b-256 |
2e31df0fe45212612df57eb76c347b40b497fdb1d1b887ea20eab0de2b2dca07
|
Provenance
The following attestation bundles were made for omni_pathlib-0.1.1-py3-none-any.whl:
Publisher:
publish-to-pypi.yml on Haskely/omni-pathlib
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
omni_pathlib-0.1.1-py3-none-any.whl -
Subject digest:
83b2f87608abb2e32094b46d9355663cbf9fc7c203a8c82f41a9471f9fceca69 - Sigstore transparency entry: 162938421
- Sigstore integration time:
-
Permalink:
Haskely/omni-pathlib@e21331049d4f5b8f88dbe846a62e35285cf28974 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/Haskely
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@e21331049d4f5b8f88dbe846a62e35285cf28974 -
Trigger Event:
push
-
Statement type: