2 Aug 2011 dyork   » (Master)

Dulwich – a native python way to access Git repositories

Ever wanted to manipulate Git repositories directly in python? Well, okay… I haven’t really myself, but in writing about Google Code’s support for git yesterday, I noticed that they are using Dulwich, a native python implementation of git. Rather than wrapping command-line git with python scripts, Dulwich is a python module giving you direct access to a git repository. As shown in the Dulwich tutorial, creating a new repo is simply this:

>>> from dulwich.repo import Repo
>>> from os import mkdir
>>> mkdir("myrepo")
>>> repo = Repo.init("myrepo")
>>> repo
<Repo at 'myrepo'>

Once a repo is created (or you connect to an existing repo), you can do what you would do with git at the command line: adding files to the repo, committing files, and changing files.

While I don’t know that I personally will use this… it’s very cool that Dulwich is out there for python programmers who want to interact with git repos. Very cool to see!

Syndicated 2011-08-02 11:49:16 from Code.DanYork.Com

Latest blog entries     Older blog entries

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!