From 5f36cbc957aec5b21a8a300e2669e06d8e5d05c8 Mon Sep 17 00:00:00 2001 From: Vincent Jacques Date: Sun, 12 Feb 2012 20:04:25 +0100 Subject: [PATCH] Add organizations --- IntegrationTest.py | 6 +++++- github/Github.py | 3 +++ github/GithubObjects.py | 12 ++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/IntegrationTest.py b/IntegrationTest.py index 1351661d..7eab2a5d 100644 --- a/IntegrationTest.py +++ b/IntegrationTest.py @@ -16,6 +16,10 @@ for r in u.get_repos(): print u = g.get_user( "nvie" ) -print u.login, u.name +print u.login, "(" + u.name + ")" print ", ".join( r.name for r in u.get_repos() ) print + +o = g.get_organization( "github" ) +print o.login, "(" + o.name + ")" +print ", ".join( u.login for u in o.get_public_members() ) diff --git a/github/Github.py b/github/Github.py index 19a4061d..73002f92 100644 --- a/github/Github.py +++ b/github/Github.py @@ -36,3 +36,6 @@ class Github: return AuthenticatedUser( self, {}, lazy = True ) else: return NamedUser( self, { "login": login }, lazy = False ) + + def get_organization( self, login ): + return Organization( self, { "login": login }, lazy = False ) diff --git a/github/GithubObjects.py b/github/GithubObjects.py index 36d90cd7..cfc25ba2 100644 --- a/github/GithubObjects.py +++ b/github/GithubObjects.py @@ -23,6 +23,18 @@ NamedUser = GithubObject( ), ) +Organization = GithubObject( + "Organization", + BaseUrl( lambda obj: "/orgs/" + obj.login ), + SimpleScalarAttributes( + "login", "id", "url", "avatar_url", "name", "company", "blog", + "location", "email", "public_repos", "public_gists", "followers", + "following", "html_url", "created_at", "type", + ), + ExtendedListAttribute( "public_members", NamedUser ), + ExtendedListAttribute( "members", NamedUser ), +) + Repository = GithubObject( "Repository", BaseUrl( lambda obj: "/repos/" + obj.owner.login + "/" + obj.name ),