Repository: tags, branches, commits

I had to rework pagination because it does not work as documented
This commit is contained in:
Vincent Jacques
2012-02-25 15:08:07 +00:00
parent 8a7ab941cd
commit bd8c8f5886
5 changed files with 117 additions and 15 deletions
+65 -1
View File
@@ -199,6 +199,56 @@ Download = GithubObject(
Deletable(),
)
CommitComment = GithubObject(
"CommitComment",
BaseUrl( lambda obj: obj._repo._baseUrl + "/comments/" + str( obj.id ) ),
InternalSimpleAttributes(
"url", "id", "body", "path", "position", "commit_id",
"created_at", "updated_at", "html_url", "line",
"_repo", ### Ugly hack
),
InternalObjectAttribute( "user", NamedUser ),
Editable( [ "body" ], [] ),
Deletable(),
)
Commit = GithubObject(
"Commit",
BaseUrl( lambda obj: obj._repo._baseUrl + "/commits/" + str( obj.sha ) ),
InternalSimpleAttributes(
"sha", "url",
"parents", ### @todo Structure
"stats", ### @todo Structure
"files", ### @todo Structure
"_repo", ### Ugly hack
),
InternalObjectAttribute( "commit", GitCommit ),
InternalObjectAttribute( "author", NamedUser ),
InternalObjectAttribute( "committer", NamedUser ),
ExternalListOfObjects( "comments", CommitComment,
ListGetable( [], [] ),
ElementCreatable( "comment", [ "body", "commit_id", "line", "path", "position" ], [] ),
),
)
Tag = GithubObject(
"Tag",
InternalSimpleAttributes(
"name", "zipball_url", "tarball_url",
"_repo", ### Ugly hack
),
InternalObjectAttribute( "commit", Commit )
)
Branch = GithubObject(
"Branch",
InternalSimpleAttributes(
"name",
"_repo", ### Ugly hack
),
InternalObjectAttribute( "commit", Commit )
)
__modifyAttributesForObjectsReferingRepo = lambda obj, attributes: dict( itertools.chain( attributes.iteritems(), { "_repo": obj }.iteritems() ) )
Repository = GithubObject(
"Repository",
@@ -259,7 +309,21 @@ Repository = GithubObject(
ListGetable( [], [], __modifyAttributesForObjectsReferingRepo ),
ElementGetable( "download", lambda repo, id : { "_repo": repo, "number": number } ),
ElementCreatable( "download", [ "name", "size" ], [ "description", "content_type" ], __modifyAttributesForObjectsReferingRepo ),
)
),
ExternalListOfObjects( "comments", CommitComment,
ListGetable( [], [], __modifyAttributesForObjectsReferingRepo ),
ElementGetable( "comment", lambda repo, id : { "_repo": repo, "id": id } ),
),
ExternalListOfObjects( "commits", Commit,
ListGetable( [], [ "sha", "path" ], __modifyAttributesForObjectsReferingRepo ),
ElementGetable( "commit", lambda repo, sha : { "_repo": repo, "sha": sha } ),
),
ExternalListOfObjects( "tags", Tag,
ListGetable( [], [], __modifyAttributesForObjectsReferingRepo ),
),
ExternalListOfObjects( "branches", Branch,
ListGetable( [], [], __modifyAttributesForObjectsReferingRepo ),
),
)
Repository._addAttributePolicy( InternalObjectAttribute( "parent", Repository ) )
Repository._addAttributePolicy( InternalObjectAttribute( "source", Repository ) )