提供 S3 路径操作,类似于 pathlib 中的 PurePath
项目描述
描述
提供 S3 路径操作,类似于 pathlib 中的 PurePath。S3Path仅用于路径操作,不实现任何与 S3 本身交互的方法。避免 S3 交互意味着用户可以使用自己的 boto3 会话,而不必强制使用默认会话。
对于执行路径操作和交互的 S3Path 实现,请参阅 s3path。
安装
这是一个纯 python 包,所以它可以与pip install s3-path-wrangler
任何其他依赖管理器一起安装。
用法
这个库提供了一个(意味着)不可变的类 - S3Path. 班级特色:
from s3_path_wrangler.paths import S3Path
# various options for creating path objects
full_path = S3Path("s3://your-bucket/some/path/file.json")
from_list = S3Path.from_parts(["your-bucket", "some", "path", "file.json"], is_absolute=True)
relative = S3Path("some/path/")
relative_from_list = S3Path.from_parts(["some", "path"]) # or is_absolute=False
# convenient attributes
assert full_path.parts == ["your-bucket", "some", "path", "file.json"]
assert full_path.is_absolute == True
assert full_path.bucket == "your-bucket"
assert full_path.key == "some/path/file.json"
assert full_path.name == "file.json"
assert full_path.parent == S3Path("s3://your-bucket/some/path")
# paths are comparable to strings (directories will not have trailing slashes)
assert S3Path.from_parts(["some", "path"]) == "some/path"
# paths can be manipulated via '/'
assert relative / "file.json" == S3Path("some/path/file.json")
发展
该库使用诗歌包管理器,必须在安装其他依赖项之前安装它。之后,运行poetry install以创建一个 virtualenv 并安装所有依赖项。
黑色用于(并通过工作流强制执行)格式化所有代码。Poetry 会自动安装它,但运行它取决于用户。要格式化整个项目,请运行black ..
要运行测试,要么通过激活 virtualenvpoetry shell并运行pytest ./tests,要么简单地运行poetry run pytest ./tests。
贡献
该项目使用 Apache 2.0 许可证,由数据科学团队 @ Barbora 维护。欢迎以 PR 或提出问题的形式提供所有贡献。
项目详情
关
s3_path_wrangler -0.5.0-py3-none-any.whl 的哈希值
| 算法 | 哈希摘要 | |
|---|---|---|
| SHA256 | 7c5e3fbfdff7617d36690d4aa1b0f5324e90dc8c55862f01308f706a4c40dfb6 |
|
| MD5 | 8d7c975be2da0b4e55fd28a7a2dac66e |
|
| 布莱克2-256 | 3f718f1a5b605c15b7608a91b8eab136b0fbbe074def19aea9c5cac91c713f13 |