GithubHelp home page GithubHelp logo

morla10111 / pyolite Goto Github PK

View Code? Open in Web Editor NEW

This project forked from presslabs/pyolite

0.0 2.0 0.0 148 KB

Python wrapper for gitolite

License: BSD 2-Clause "Simplified" License

Python 99.91% ApacheConf 0.09%

pyolite's Introduction

pyolite Build Status Coverage Status Downloads

Python wrapper for gitolite

Easy and simple to user, just pip install pyolite and boom!!!

Using an intuitive API, pyolite help you easly create users and repos using gitolite.

Repository API

First, we need to initialize a pyolite object with the path to gitolite's repository.

from pyolite import Pyolite

# initial olite object
admin_repository = '/home/absolute/path/to/gitolite/repo/'
olite = Pyolite(admin_repository=admin_repository)

After that, we can create and get a repo using create and get methods.

# create a repo
repo = olite.repos.get('my_repo')
repo = olite.repos.create('ydo')
repo = olite.repos.get_or_create('second_repo')

Every repo has an users object, in order to facilitate basic operations: adding, editing and removing users from a repository.

print "Repo's users: %s" % repo.users

user = olite.users.create(name='bob', key_path="~/.ssh/third_rsa.pub")

# add a new user
repo.users.add(olite.users.get('admin'), permission='W+')
repo.users.add('bob', permission='R')

# change user's permissions
repo.users.edit(olite.users.get('admin'), permission='WR+')
repo.users.edit('bob', permission='RCW')

# remove user
repo.users.remove('admin')

Users API

You an easly manipulate users aswell, using allmost the same API.

from pyolite import Pyolite

# initial olite object
admin_repository = '/home/absolute/path/to/gitolite/repo/'
olite = Pyolite(admin_repository=admin_repository)

# create user object
vlad = olite.users.create(name='bob',
                          key_path='~/.ssh/second_rsa.pub')

# get user by name
vlad = olite.users.get(name='admin')

# get_or_create django style
vlad = olite.users.get_or_create('alice')

# add new key to user
vlad.keys.append('/path/to/key')
vlad.keys.append('just put the key here')

# check if user is admin or not
print vlad.is_admin

If you need any help with this module, write me [email protected]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.