Provides S3 path manipulation, similar to PurePath in pathlib
Project description
Description
Provides S3 path manipulation, similar to PurePath in pathlib. S3Path is only meant for path manipulation and does not implement any methods which interact with S3 itself. Avoiding S3 interaction means that a user can use their own boto3 session and are not forced to use the default one.
For S3Path implementations that do path manipulation and interaction, see s3path instead.
Installation
This is a pure python package, so it can be installed with pip install s3-path-wrangler
or any other dependency manager.
Usage
This library provides a single (meant to be) immutable class - S3Path
.
Class features:
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")
Development
This library uses the poetry package manager, which has to be installed before installing
other dependencies. Afterwards, run poetry install
to create a virtualenv and install all dependencies.
Black is used (and enforced via workflows) to format all code. Poetry will install it
automatically, but running it is up to the user. To format the entire project, run black .
.
To run tests, either activate the virtualenv via poetry shell
and run pytest ./tests
,
or simply run poetry run pytest ./tests
.
Contributing
This project uses the Apache 2.0 license and is maintained by the data science team @ Barbora. All contribution are welcome in the form of PRs or raised issues.
Project details
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
File details
Details for the file s3-path-wrangler-0.5.0.tar.gz
.
File metadata
- Download URL: s3-path-wrangler-0.5.0.tar.gz
- Upload date:
- Size: 9.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.7 CPython/3.9.6 Linux/5.8.0-1036-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 47da0fe4fd115f790026b261066d7ac3ac93b6075cdd7297b1610f20f17c6f56 |
|
MD5 | 2cffdf948b58bbf7e95dd1f8920e5bb6 |
|
BLAKE2b-256 | 547d7b6e161dfb061de53347bbb18b458371bb30426bc90bd944d8c2d84ab1b0 |
File details
Details for the file s3_path_wrangler-0.5.0-py3-none-any.whl
.
File metadata
- Download URL: s3_path_wrangler-0.5.0-py3-none-any.whl
- Upload date:
- Size: 9.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.7 CPython/3.9.6 Linux/5.8.0-1036-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7c5e3fbfdff7617d36690d4aa1b0f5324e90dc8c55862f01308f706a4c40dfb6 |
|
MD5 | 8d7c975be2da0b4e55fd28a7a2dac66e |
|
BLAKE2b-256 | 3f718f1a5b605c15b7608a91b8eab136b0fbbe074def19aea9c5cac91c713f13 |