Repository issues

This commit is contained in:
Vincent Jacques
2012-02-24 14:57:26 +00:00
parent f9a882fcae
commit ce2135c961
5 changed files with 43 additions and 9 deletions
+3
View File
@@ -163,6 +163,8 @@ class IntegrationTest:
m.edit( title = m.title, description = "And the description was modified by PyGithub as well" )
m = r.create_milestone( title = "This milestone was also created by PyGithub" )
m.delete()
i = r.create_issue( "Issue created by PyGithub" )
i.edit( body = "Body edited by PyGithub" )
self.dumpRepository( r )
@@ -215,6 +217,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 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
+6 -6
View File
@@ -235,13 +235,13 @@ API `/repos/:user/:repo/hooks/:id/test`
API `/repos/:user/:repo/issues`
===============================
* GET: (TODO SOON)
* POST: (TODO SOON)
* GET: `Repository.get_issues( ... )`: list of `Issue`
* POST: `Repository.create_issue( ... )`: `Issue`
API `/repos/:user/:repo/issues/:id`
===================================
* GET: (TODO SOON)
* PATCH: (TODO SOON)
* GET: `Repository.get_issue( id )`: `Issue`
* PATCH: `Issue.edit( ... )`
API `/repos/:user/:repo/issues/:id/comments`
============================================
@@ -259,8 +259,8 @@ API `/repos/:user/:repo/issues/:id/labels/:id`
==============================================
* DELETE: (TODO SOON)
API `/repos/:user/:repo/issues/:issue_id/events`
================================================
API `/repos/:user/:repo/issues/:id/events`
==========================================
* GET: (TODO)
API `/repos/:user/:repo/issues/comments/:id`
+9 -1
View File
@@ -142,16 +142,24 @@ Issues and milestones
* `get_labels()`: list of `Label`
* `create_label( ... )`: `Label`: see [API](http://developer.github.com/v3/issues/labels/#create-a-label) for parameters
* `get_label( id )`: `Label`
* `get_issues( ... )`: list of `Issue`: see [API](http://developer.github.com/v3/issues/#list-issues-for-a-repository) for parameters
* `create_issue( ... )`: `Issue`: see [API](http://developer.github.com/v3/issues/#create-an-issue) for parameters
* `get_issue( id )`: `Issue`
* `get_milestones( ... )`: list of `Milestone`: see [API](http://developer.github.com/v3/issues/milestones/#list-milestones-for-a-repository) for parameters
* `create_milestone( ... )`: `Milestone`: see [API](http://developer.github.com/v3/issues/milestones/#create-a-milestone) for parameters
* `get_milestone( number )`: `Milestone`
Class `Label`
================
=============
* Attributes: see [API](http://developer.github.com/v3/issues/labels/#get-a-single-label)
* `edit( ... )`: see [API](http://developer.github.com/v3/issues/labels/#update-a-label) for parameters
* `delete()`
Class `Issue`
=============
* Attributes: see [API](http://developer.github.com/v3/issues/#get-a-single-issue)
* `edit( ... )`: see [API](http://developer.github.com/v3/issues/#edit-an-issue) for parameters
Class `Milestone`
================
* Attributes: see [API](http://developer.github.com/v3/issues/milestones/#get-a-single-milestone)
+4 -1
View File
@@ -38,7 +38,10 @@ class ComplexAttribute:
self.__type = type
def getValueFromRawValue( self, obj, rawValue ):
return self.__type( obj._github, rawValue, lazy = True )
if rawValue is None:
return None
else:
return self.__type( obj._github, rawValue, lazy = True )
def updateAttributes( self, obj ):
attributes = obj._github._dataRequest( "GET", obj._baseUrl, None, None )
+21 -1
View File
@@ -141,6 +141,21 @@ Milestone = GithubObject(
ListAttribute( "labels", Label, ListGetable( [], [], lambda obj, attributes: dict( itertools.chain( attributes.iteritems(), { "_repo": obj._repo }.iteritems() ) ) ) ),
)
Issue = GithubObject(
"Issue",
BaseUrl( lambda obj: obj._repo._baseUrl + "/issues/" + str( obj.number ) ),
BasicAttributes(
"url", "html_url", "number", "state", "title", "body", "labels",
"comments", "closed_at", "created_at", "updated_at", "id", "closed_by",
"pull_request", ### @todo Structure
"_repo", ### Ugly hack
),
ComplexAttribute( "user", NamedUser ),
ComplexAttribute( "assignee", NamedUser ),
ComplexAttribute( "milestone", Milestone ),
Editable( [], [ "title", "body", "assignee", "state", "milestone", "labels" ] ),
)
__modifyAttributesForObjectsReferingRepo = lambda obj, attributes: dict( itertools.chain( attributes.iteritems(), { "_repo": obj }.iteritems() ) )
Repository = GithubObject(
"Repository",
@@ -190,7 +205,12 @@ Repository = GithubObject(
ListGetable( [], [ "state", "sort", "direction" ], __modifyAttributesForObjectsReferingRepo ),
ElementGetable( "milestone", lambda repo, number: { "_repo": repo, "number": number } ),
ElementCreatable( "milestone", [ "title" ], [ "state", "description", "due_on" ], __modifyAttributesForObjectsReferingRepo )
)
),
ListAttribute( "issues", Issue,
ListGetable( [], [ "milestone", "state", "assignee", "mentioned", "labels", "sort", "direction", "since" ], __modifyAttributesForObjectsReferingRepo ),
ElementGetable( "issue", lambda repo, number: { "_repo": repo, "number": number } ),
ElementCreatable( "issue", [ "title" ], [ "body", "assignee", "milestone", "labels", ], __modifyAttributesForObjectsReferingRepo )
),
)
Repository._addAttributePolicy( ComplexAttribute( "parent", Repository ) )
Repository._addAttributePolicy( ComplexAttribute( "source", Repository ) )