This is a Python module for s3git. Please see here for a general introduction to s3git including its use cases.
This module is based on the s3git-go package that is invoked via foreign function interface (FFI).
DISCLAIMER: This software is still under development (although the storage format/model is stable) -- use at your own peril for now
Note that the API is not stable yet, you can expect minor changes/extensions
Please make sure you have a working Golang environment installed, otherwise you cannot build the shared library. See install golang for setting up a working Golang environment.
Also the s3git-go package needs to be available locally (go get -d github.com/s3git/s3git-go
).
$ go build -buildmode=c-shared -o s3git-py.so
Here are some common examples of typical tasks.
$ python3
>>> import s3git
>>> repo = s3git.init_repository('.')
>>> repo.add('hello s3git')
>>> repo.commit('My first s3git commit from Python')
>>> exit()
$ s3git log --pretty
113b9e900588fd830deed131c0f2f2cdd88b4751286ecc4967d0d4990aff6821c2426425955ec104797b142e93204a604e4ba420b3b617724237476128333de8 My first s3git commit from Python
$ s3git ls
c518dc5f1d95258dc91f6d285e7ea7300f37dea4dd517173f2e23afe0cb52bc9d8eb18683cdcf377e96a2d5a81585e61f6d27fa5d017cad53836bd050e9f105f
$ s3git cat c518dc5f1d95258dc91f6d285e7ea7300f37dea4dd517173f2e23afe0cb52bc9d8eb18683cdcf377e96a2d5a81585e61f6d27fa5d017cad53836bd050e9f105f
hello s3git
>>> import s3git
>>> repo = s3git.clone('s3://s3git-spoon-knife', '.', access='AKIAJYNT4FCBFWDQPERQ', secret='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')
>>> for l in repo.list(''):
>>> print(l)
>>> import s3git
>>> repo = s3git.init_repository('.')
>>> repo.add('hello s3git')
>>> repo.add('Python rocks')
>>> repo.add(open('local-file.txt', 'rb'))
>>> for l in repo.list(''):
>>> repo.get(l).read()
>>> import s3git
>>> repo = s3git.init_repository('.')
>>> repo.add('string 1')
>>> repo.commit('first commit')
>>> repo.add('string 2')
>>> repo.commit('second commit')
>>> for c in repo.list_commits():
>>> print(c['Message'])
>>> import s3git
>>> repo = s3git.init_repository('.')
>>> repo.add('just some stuff')
>>> repo.add('more stuff')
>>> repo.add('and yet more stuff')
>>> repo.commit('initial commit')
>>> repo.remote_add('primary', 's3://s3git-spoon-knife', access='AKIAJYNT4FCBFWDQPERQ', secret='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')
>>> repo.push()
>>> import s3git
>>> repo = s3git.init_repository('.')
>>> repo.snapshot_create("Initial snapshot")
>>> repo.snapshot_list("")
- Streams are not yet natively supported (temp files are used under the hood)
- Methods that return arrays (eg. list or list_commits) are currently limited to a maximum of 1000 responses
- Proper error handling is largely missing
Contributions are welcome, please submit a pull request for any enhancements.
s3git-rb is released under the Apache License v2.0. You can find the complete text in the file LICENSE.