A polite interface for sending python objects to and from Amazon S3.
## Installation
```
pip install s3pyo
```
## Tests
**NOTE** very basic for now. They also assume you have set `AWS_ACCESS_KEY_ID` and
`AWS_ACCESS_KEY_SECRET` as environmental variables and
```
nosetests
```
## Bacic Usage
```python
import s3pyo
# return an `s3pyo.S3` object with
# methods for sending objects
# to and from Amazon S3.
plz = s3pyo.please('s3://asteroid',
key='navigate',
secret='shield',
serializer="json.gz",
public = False
)
# You can also set `AWS_ACCESS_KEY_ID` and
# `AWS_ACCESS_KEY_SECRET` as environmental variables
# Serialize an object, format its
# filepath, put it on s3, and return
# the formatted filepath (with an absolute s3path)
# for your records
obj = {"key": "value"}
filepath = 'test/{key}.json.gz'
fp = plz.put(obj, filepath, **obj)
print fp
# >>> 's3://my-bucket/test/value.json.gz'
# you can now fetch this object with its filepath
obj = plz.get(fp)
assert(obj == obj)
```
## Customization.
## Filepaths
`s3pyo` will attempt to format your filepath
for you given arbitary `**kwargs` passed to
any method. You also have access to utility values
accessed by the "@" operator these include:
- '@second': "56"
- '@minute': "54"
- '@hour': : "23"
- '@day': "29"
- '@month': "01"
- '@year': : "2014,
- '@timestamp' : "1234567"
- '@date_path' : "2014/01/14"
- '@date_slug' : "2014-01-14,
- '@datetime_slug' : "2013-12-12-06-08-52"
- '@uid': 'dasfas-23r32-sad-3sadf-sdf"
**NOTE** ALL TIME VARIABLES ARE CURRENT UTC.
For instance,
``` python
import s3pyo
obj = {"key": "value"}
filepath = 'test/{key}/{@date_path}/{@uid}.json.gz'
plz = s3pyo.please('s3://my-bucket')
fp = plz.put(obj, filepath, **obj)
print fp
# >>> 's3://my-bucket/value/2014/08/25/3225-sdsa-35235-asdfas-235.json.gz'
```
### Serialization
By default, you can serialize / deserialize objects to / from `json.gz`,
`json`, or `gz` (set with `serialize` via `s3pyo.please`. However, you can also inherit from the core `s3pyo.S3` class and overwrite the `serialize` and `deserialize` methods.
```python
from s3pyo import S3
class SqlAlchemyToS3(S3):
def serialize(self, obj):
return "Do something hipster here."
def deserialize(self, string):
return "Undo it."
plz = SqlAlchemyToS3('s3://bucket')
print plz.get('s3://bucket/file.mycoolformat')
# >>> `A SqLAlchemy Model`
```
_I can assure you they will never get me onto one of those dreadful buckets._
Metadata
Release files for s3pyo 0.0.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 |
|---|---|---|---|---|
| s3pyo-0.0.2.tar.gz | 4.9 kB | Without provenance | Details for s3pyo-0.0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| s3pyo-0.0.2.macosx-10.10-intel.exe | Details for s3pyo-0.0.2.macosx-10.10-intel.exe |
Total release size: 75.1 kB
Release files / s3pyo-0.0.2.tar.gz
| Download URL | s3pyo-0.0.2.tar.gz |
|---|---|
| Size | 4.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
53010b6dd89378a58af0532aecd69a21c127f0c7d84c507a37720a474421db59
|
|
BLAKE2b-256 checksum How to use checksums |
f875b1db030effdfbae2c59ef530a7098d6a3fb1ab2db0e5d90eba1e378e0bb2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / s3pyo-0.0.2.macosx-10.10-intel.exe
| Download URL | s3pyo-0.0.2.macosx-10.10-intel.exe |
|---|---|
| Size | 70.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
87f7fff09da398f2d03e41e55230e17af6a38b4d741b4a831ea30e9a37a29ebc
|
|
BLAKE2b-256 checksum How to use checksums |
b2880996d1eef0a2b81e3a6b64d224a08ce7e5fef2f11cdffe1db5b7cf86519f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for s3pyo 0.0.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.