Skip to main content
Donate to the Python Software Foundation or Purchase a PyCharm License to Benefit the PSF! Donate Now

Object-oriented paths in Git repositories

Project description

An read-only implementation of Python’s pathlib that works on Git trees.

Installation

This library requires pygit2, which can be hard to install. You may need to get it installed before installing gitpathlib.

In a Python 3 virtual environment, do:

python -m pip install gitpathlib

To install an editable from a Git checkout:

python -m pip install -e.

To install without a virtual envitonment, add the --user option.

Basic Usage

A GitPath can be created from a path to a Git repository, and a commit (or tree) in it:

from gitpathlib import GitPath

head = GitPath('path/to/git/repo', 'HEAD')

It can then be used as a Path would:

path = head / 'dir' / 'file.txt'
with path.open() as f:
    contents = f.read()

GitPath provides read-only access. Creating files, opening them in write mode, etc. are not supported.

Development

You’re welcome to join this project!

If you spot an issue, please report it at the Issues page on Github.

If you’d like to start changing the code or documentation, check out the code locally using:

git clone https://github.com/encukou/gitpathlib

If you’re new to this, please read the this guide about collaborating on Github-hosted projects like this one.

If that doesn’t make sense, please e-mail the author for clarification. I’d be happy to help you get started.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
gitpathlib-0.2-py3-none-any.whl (15.7 kB) Copy SHA256 hash SHA256 Wheel py3
gitpathlib-0.2.tar.gz (14.2 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page