libs3
The purpose of this repo is to provide an easy to use interface to s3 for python developers, the code python libraries like os, shutil are easy to use and more familier to any python programmer.
The repo aims to mimic the functionality so that your code will interact with s3 in same way as it is interacting in linux or windows filesystem, with 1 or 2 line change
Installation
pip install libs3
Documentation
A list of functions have been exposed which are working as of now and more will be added later (contributions are welcome)
os
| Function | Availaible | Comments |
|---|---|---|
os.listdir(x) |
yes | As s3 has no notion of directories, in order to list directories along with files we have to traverse entire bucket and filter the results. For more quick results you can use os.listdir(x, filesonly=True) is much fast but will only returns files and not directory |
os.mkdir(x) |
no | As s3 has no concept of directory, we cannot create an empty directory |
os.makedirs(x) |
no | As s3 has no concept of directory, we cannot create an empty directory |
os.remove(x) |
no | will be added in later releases |
os.removedirs(x) |
no | will be added in later releases |
os.rmdir(x) |
no | will be added in later releases |
os.rename(x) |
no | will be added in later releases |
os.renames(x) |
no | will be added in later releases |
os.replace(x) |
no | will be added in later releases |
os.scandir(x) |
no | will be added in later releases |
os.walk(x) |
no | will be added in later releases |
os.path
| Function | Availaible | Comments |
|---|---|---|
os.path.basename(x) |
yes | |
os.path.commonpath(x) |
no | will be added in later releases |
os.path.commonprefix(x) |
no | will be added in later releases |
os.path.dirname(x) |
yes | |
os.path.exists(x) |
yes | |
os.path.isfile(x) |
yes | |
os.path.isdir(x) |
yes | |
os.path.join(x) |
no | will be added in later releases |
shutil
| Function | Availaible | Comments |
|---|---|---|
shutil.copyfile |
no | will be added in later releases |
shutil.copy |
no | will be added in later releases |
shutil.copytree |
no | will be added in later releases |
shutil.rmtree |
no | will be added in later releases |
shutil.move |
no | will be added in later releases |
shutil.disk_usage |
no | will be added in later releases |
Example
Importing the module and authorizing using s3 credentials
from libs3 import os
os.authorize(bucket, aws_access_key_id, aws_secret_access_key)
After authorizing access the interface like normally accessing filesystem
print(os.listdir("/dir_1/dir_1"))
print(os.listdir("/dir_1/dir_1", filesonly=True)) # Much quicker
print(os.path.exists('/dir_1/file_2'))
print(os.path.isfile('/dir_1/file_2'))
print(os.path.isdir('/dir_1/file_2'))
print(os.path.basename('/dir_1/file_2'))
print(os.path.dirname('/dir_1/file_2'))
Release files for libs3 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 | |
|---|---|---|---|
| libs3-0.0.2.tar.gz | 3.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| libs3-0.0.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 7.6 kB
Release files / libs3-0.0.2.tar.gz
| Download URL | libs3-0.0.2.tar.gz |
|---|---|
| Size | 3.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
82ad15cf899d7a576172b661fdea8ff395f770cf91fce87c5017e2f87719e124
|
|
BLAKE2b-256 checksum How to use checksums |
0a1f82a304f5b2e1f0ca3167927ef1473eebb546d4d78dbfa300900d27d4fe35
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.4
|
Release files / libs3-0.0.2-py3-none-any.whl
| Download URL | libs3-0.0.2-py3-none-any.whl |
|---|---|
| Size | 4.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d903e3f1cd1d1692b90eeda257b51c066082c19282567cb8322a39ec7e457e28
|
|
BLAKE2b-256 checksum How to use checksums |
e522874f3a30e95eb1730ca62bbe85a60dca0956524b914f7fa9b461a9ae3326
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.4
|