From c3db56f0fda42f5ff444bf7824f75c69353d33c7 Mon Sep 17 00:00:00 2001 From: Vincent Jacques Date: Fri, 24 Feb 2012 17:10:02 +0000 Subject: [PATCH] IssueComment --- IntegrationTest.py | 4 +++- ReferenceOfApis.md | 10 +++++----- ReferenceOfClasses.md | 9 +++++++++ github/GithubObjects.py | 17 +++++++++++++++++ 4 files changed, 34 insertions(+), 6 deletions(-) diff --git a/IntegrationTest.py b/IntegrationTest.py index 13975aa2..765706a9 100644 --- a/IntegrationTest.py +++ b/IntegrationTest.py @@ -174,6 +174,8 @@ class IntegrationTest: i.delete_labels() i.add_to_labels( lc ) + i.create_comment( "Commented from PyGithub" ) + self.dumpRepository( r ) def dumpUser( self, u ): @@ -225,7 +227,7 @@ class IntegrationTest: print base64.b64decode( blob.content ), print print " Labels:", ", ".join( l.name + " (" + l.color + ")" for l in r.get_labels() ) - print " Issues:", ", ".join( i.title + " (" + ", ".join( l.name for l in i.get_labels() ) + ")" for i in r.get_issues() ) + print " Issues:", ", ".join( i.title + " (" + ", ".join( l.name for l in i.get_labels() ) + ") (" + ", ".join( c.body for c in i.get_comments() ) + ")" for i in r.get_issues() ) print " Milestones:", ", ".join( m.title + " (created by " + m.creator.login + ", " + ", ".join( l.name for l in m.get_labels() ) + ")" for m in r.get_milestones() ) print " Closed milestones:", ", ".join( m.title for m in r.get_milestones( state = "closed" ) ) print diff --git a/ReferenceOfApis.md b/ReferenceOfApis.md index af6b16cc..32db733a 100644 --- a/ReferenceOfApis.md +++ b/ReferenceOfApis.md @@ -245,8 +245,8 @@ API `/repos/:user/:repo/issues/:id` API `/repos/:user/:repo/issues/:id/comments` ============================================ -* GET: (TODO SOON) -* POST: (TODO SOON) +* GET: `Issue.get_comments()`: list of `IssueComment` +* POST: `Issue.create_comment( ... )`: `IssueComment` API `/repos/:user/:repo/issues/:id/labels` ========================================== @@ -265,9 +265,9 @@ API `/repos/:user/:repo/issues/:id/events` API `/repos/:user/:repo/issues/comments/:id` ============================================ -* GET: (TODO SOON) -* PATCH: (TODO SOON) -* DELETE: (TODO SOON) +* GET: `Issue.get_comment( id )`: `IssueComment` +* PATCH: `IssueComment.edit( ... )` +* DELETE: `IssueComment.delete( ... )` API `/repos/:user/:repo/issues/events` ====================================== diff --git a/ReferenceOfClasses.md b/ReferenceOfClasses.md index 119529a2..9b51fea3 100644 --- a/ReferenceOfClasses.md +++ b/ReferenceOfClasses.md @@ -164,6 +164,15 @@ Class `Issue` * `set_labels( label, ... )` * `delete_labels()` * `remove_from_labels( label )` +* `get_comments()`: list of `IssueComment` +* `create_comment( ... )`: `IssueComment`: see [API](http://developer.github.com/v3/issues/comments/#create-a-comment) for parameters +* `get_comment( id )`: `IssueComment` + +Class `IssueComment` +==================== +* Attributes: see [API](http://developer.github.com/v3/issues/comments/#get-a-single-comment) +* `edit( ... )`: see [API](http://developer.github.com/v3/issues/comments/#edit-a-comment) for parameters +* `delete()` Class `Milestone` ================ diff --git a/github/GithubObjects.py b/github/GithubObjects.py index e3649d2b..9ec6f746 100644 --- a/github/GithubObjects.py +++ b/github/GithubObjects.py @@ -142,6 +142,18 @@ Milestone = GithubObject( ListAttribute( "labels", Label, ListGetable( [], [], lambda obj, attributes: dict( itertools.chain( attributes.iteritems(), { "_repo": obj._repo }.iteritems() ) ) ) ), ) +IssueComment = GithubObject( + "IssueComment", + BaseUrl( lambda obj: obj._repo._baseUrl + "/issues/comment" + str( obj.id ) ), + BasicAttributes( + "url", "body", "created_at", "updated_at", "id", + "_repo", ### Ugly hack + ), + ComplexAttribute( "user", NamedUser ), + Editable( [ "body" ], [] ), + Deletable(), +) + Issue = GithubObject( "Issue", BaseUrl( lambda obj: obj._repo._baseUrl + "/issues/" + str( obj.number ) ), @@ -162,6 +174,11 @@ Issue = GithubObject( ListDeletable(), ElementRemovable(), ), + ListAttribute( "comments", IssueComment, + ListGetable( [], [], lambda obj, attributes: dict( itertools.chain( attributes.iteritems(), { "_repo": obj._repo }.iteritems() ) ) ), + ElementGetable( "comment", lambda repo, id: { "_repo": repo, "id": id } ), + ElementCreatable( "comment", [ "body" ], [], lambda obj, attributes: dict( itertools.chain( attributes.iteritems(), { "_repo": obj._repo }.iteritems() ) ) ), + ), ) __modifyAttributesForObjectsReferingRepo = lambda obj, attributes: dict( itertools.chain( attributes.iteritems(), { "_repo": obj }.iteritems() ) )