SDK Utils
一个用于SDK开发的工具库,提供构建Python SDK的通用功能。目前主要封装了百度云盘的常用操作,使开发者能够轻松地在自己的应用中集成百度云盘功能。
安装方法
pip install sdk_utils
主要功能
- 百度云盘API客户端
- 文件上传、下载、分享、移动、复制、删除等基本功能
- 目录操作、文件搜索和大文件分片上传等高级功能
- OAuth2.0授权认证流程
- API客户端工具
- 认证辅助工具
- 速率限制和重试机制
- 响应解析和错误处理
- 日志记录和调试工具
使用示例
百度云盘客户端
from sdk_utils.baidu_cloud import BaiduCloudClient
# 创建百度云盘客户端
client = BaiduCloudClient(
app_key="your_app_key",
secret_key="your_secret_key",
access_token="your_access_token", # 可选,如果已有token
refresh_token="your_refresh_token" # 可选,用于自动刷新token
)
# 获取授权URL(如果没有access_token)
auth_url = client.get_auth_url(redirect_uri="http://localhost:8000/callback")
print(f"请访问此URL进行授权: {auth_url}")
# 通过授权码获取token
token_info = client.get_access_token(code="authorization_code", redirect_uri="http://localhost:8000/callback")
# 上传文件
result = client.upload_file(local_path="/path/to/local/file.txt", remote_path="/apps/your_app/file.txt")
# 下载文件
client.download_file(remote_path="/apps/your_app/file.txt", local_path="/path/to/save/file.txt")
# 获取文件列表
file_list = client.list_files(dir_path="/apps/your_app")
for file in file_list:
print(f"文件名: {file['server_filename']}, 大小: {file['size']}")
使用bypy封装的百度云盘工具
from sdk_utils.baidu_cloud_bypy import BaiduPanTools
# 创建工具实例(首次使用会自动进行授权)
pan = BaiduPanTools()
# 上传文件
pan.upload_file("test_upload.txt")
# 下载文件
pan.download_file("test_upload.txt", "downloads")
# 查看文件列表
file_list = pan.list_files()
print(file_list)
# 同步整个文件夹
pan.sync_folder("local_folder", "remote_folder")
文档
完整文档请访问我们的文档站点。
开发文档
如果您想参与开发,请查看开发者指南了解更多信息。
贡献
欢迎贡献代码!请随时提交Pull Request。
贡献步骤:
- Fork 项目仓库
- 创建功能分支
- 提交变更
- 运行测试确保通过
- 提交 Pull Request
许可证
本项目采用MIT许可证 - 详情请参阅LICENSE文件。
Metadata
Release files for sdk-utils 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| sdk_utils-0.1.2.tar.gz | 65.4 kB | Without provenance | Details for sdk_utils-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| sdk_utils-0.1.2-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details for sdk_utils-0.1.2-py2.py3-none-any.whl |
Total release size: 78.4 kB
Release files / sdk_utils-0.1.2.tar.gz
| Download URL | sdk_utils-0.1.2.tar.gz |
|---|---|
| Size | 65.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a5eeba0fb5b9eab6f183f16d6ec493eebbb2793288bf6fcaec6952f76c71b5f8
|
|
BLAKE2b-256 checksum How to use checksums |
27eb8356890adafdaf7c9beb4a9ef106f2bfe3033dc17b02ca6583c84533371d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.8.20
|
Release files / sdk_utils-0.1.2-py2.py3-none-any.whl
| Download URL | sdk_utils-0.1.2-py2.py3-none-any.whl |
|---|---|
| Size | 13.0 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
8733a537c4e0042a0d935d505c3eecca999345b5d976590f813999ccf1ff2880
|
|
BLAKE2b-256 checksum How to use checksums |
0b89abc307f59108a76cbbfd83746e76faba33fa886fa7533409033aa0c5d869
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.8.20
|
Security for sdk-utils 0.1.2
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.