From c10b01e84a9a262c00e46d7a4f315d66bea4fb94 Mon Sep 17 00:00:00 2001 From: Gauvain Pocentek Date: Sat, 16 Feb 2013 09:55:22 +0100 Subject: [PATCH] move documentation and todo to README.md --- README.md | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ TODO | 4 ---- gitlab.py | 29 ---------------------------- 3 files changed, 57 insertions(+), 33 deletions(-) create mode 100644 README.md delete mode 100644 TODO diff --git a/README.md b/README.md new file mode 100644 index 000000000..da2cc2fea --- /dev/null +++ b/README.md @@ -0,0 +1,57 @@ +## Python GitLab + +python-gitlab is a Python module providing access to the GitLab server API. + +It supports the v3 api of GitLab. + +## Requirements + +Only Python 2 is supported for the moment. + +python-gitlab depends on [python-requests](http://docs.python-requests.org/en/latest/). + +## State + +python-gitlab is a work in progress, although already usable. Changes in the API might happen. + +## ToDo + +* Improve documentation +* Write unit tests +* Write a command line tool to access GitLab servers + +## Code snippet + +`````python +# See https://github.com/gitlabhq/gitlabhq/tree/master/doc/api for the source. + +# Register a connection to a gitlab instance, using its URL and a user private +# token +gl = Gitlab('http://192.168.123.107', 'JVNSESs8EwWRx5yDxM5q') +# Connect to get the current user +gl.auth() +# Print the user informations +print gl.user + +# Get a list of projects +for p in gl.Project(): + print (p.name) + # get associated issues + issues = p.Issue() + for issue in issues: + closed = 0 if not issue.closed else 1 + print (" %d => %s (closed: %d)" % (issue.id, issue.title, closed)) + # and close them all + issue.closed = 1 + issue.save() + +# Get the first 10 groups (pagination) +for g in gl.Group(page=1, per_page=10): + print (g) + +# Create a new project +p = gl.Project({'name': 'myCoolProject', 'wiki_enabled': False}) +p.save() +print p +````` + diff --git a/TODO b/TODO deleted file mode 100644 index 534b95953..000000000 --- a/TODO +++ /dev/null @@ -1,4 +0,0 @@ -- better error checking -- documentation -- implement some missing methods - diff --git a/gitlab.py b/gitlab.py index 2da2b467c..b40239c6a 100644 --- a/gitlab.py +++ b/gitlab.py @@ -619,32 +619,3 @@ def Tag(self, id=None, **kwargs): return self._getListOrObject(ProjectTag, id, project_id=self.id, **kwargs) - - -if __name__ == '__main__': - # Quick "doc" - # - # See https://github.com/gitlabhq/gitlabhq/tree/master/doc/api for the - # source - - # Register a connection to a gitlab instance, using its URL and a user - # private token - gl = Gitlab('http://192.168.123.107:8080', 'JVNSESs8EwWRx5yDxM5q') - # Connect to get the current user (as gl.user) - gl.auth() - - # get a list of projects - for p in gl.Project(): - print p.name - # get associated issues - issues = p.Issue() - for issue in issues: - closed = 0 if not issue.closed else 1 - print " %d => %s (closed: %d)" % (issue.id, issue.title, closed) - # and close them all - issue.closed = 1 - issue.save() - - # get the first 10 groups (pagination) - for g in gl.Group(page=1, per_page=10): - print g