Access a git repository like a python dict
One of the main goals - beside providing a nice git access - is to use this in a pyramid web application with a traversal style routing. There is a small example pyramid project to demonstrate this. Of cause, the package can also be used otherwise ;-)
The documentation consists mainly of examples.
Introduction by Example
# open a Repository import gitdict repo = Repository('/path/to/gitdict.git') # read a folder and a file from the repository folder = repo['docs'] file = folder['index.md'] # access to file data file.data == b'gitdict - Dict Like Access […]' file.text == 'gitdict - Dict Like Access […]' # iterate over lines in a file, just like with standard python open() for line in file: do_something(line) # data about the last change to the file last_change = file.last_commit last_change.message == 'latest commit message' last_change.author == pygit2.Signature('Holger Frey', 'firstname.lastname@example.org') # all changes done to a file file.history == [commit_3, commit_2, commit_1] # difference between current and a previous version patch = file.diff(commit_1)
There are three main classes in the gitdict package:
- Repository: used to open a git repository, acts also as the ‘root folder’
- Folder: like a folder in the file system, located inside a repository
- File: like a file in the file system, stores data and is located inside a folder
A Folder or a File object should not be created directly but retrieved either from a Repository or another Folder.
Some methods just act as a proxy to the underlying pygit2 object, others do some extra work. In some cases pygit2 object are directly exposed to the user. But this only happens where simplification is not needed, IMHO.
Note of Warning
This package was developed on Mac OS X and Python 3.5. There is currently no such thing as testing on other platforms or Python versions.
If the installation with python3 setup.py doesn’t work, try to install pygit2 manually first - this is the tricky part. E.g. on my setup the cffi-package was missing.
In other words: Works for me ;-)
Well, I decided to go with the Simplified BSD License.
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size gitdict-0.1.2.tar.gz (9.3 kB)||File type Source||Python version None||Upload date||Hashes View hashes|