diff --git a/github/Branch.py b/github/Branch.py new file mode 100644 index 00000000..840a4d62 --- /dev/null +++ b/github/Branch.py @@ -0,0 +1,12 @@ +from GithubObject import * + +from Commit import Commit + +Branch = GithubObject( + "Branch", + InternalSimpleAttributes( + "name", + "_repo", + ), + InternalObjectAttribute( "commit", Commit ) +) diff --git a/github/Commit.py b/github/Commit.py new file mode 100644 index 00000000..992087e1 --- /dev/null +++ b/github/Commit.py @@ -0,0 +1,26 @@ +from GithubObject import * + +from GitCommit import GitCommit +from NamedUser import NamedUser +from CommitComment import CommitComment + +__modifyAttributesForObjectsReferingReferedRepo = { "_repo": lambda obj: obj._repo } + +Commit = GithubObject( + "Commit", + BaseUrl( lambda obj: obj._repo._baseUrl() + "/commits/" + str( obj.sha ) ), + InternalSimpleAttributes( + "sha", "url", + "parents", + "stats", + "files", + "_repo", + ), + InternalObjectAttribute( "commit", GitCommit ), + InternalObjectAttribute( "author", NamedUser ), + InternalObjectAttribute( "committer", NamedUser ), + ExternalListOfObjects( "comments", "comment", CommitComment, + ListGetable( [], [], __modifyAttributesForObjectsReferingReferedRepo ), + ElementCreatable( [ "body" ], [ "commit_id", "line", "path", "position" ], __modifyAttributesForObjectsReferingReferedRepo ), + ), +) diff --git a/github/GithubObjects.py b/github/GithubObjects.py index 9480ba45..98b02707 100644 --- a/github/GithubObjects.py +++ b/github/GithubObjects.py @@ -76,43 +76,9 @@ Issue = GithubObject( from Download import Download from CommitComment import CommitComment - -Commit = GithubObject( - "Commit", - BaseUrl( lambda obj: obj._repo._baseUrl() + "/commits/" + str( obj.sha ) ), - InternalSimpleAttributes( - "sha", "url", - "parents", - "stats", - "files", - "_repo", - ), - InternalObjectAttribute( "commit", GitCommit ), - InternalObjectAttribute( "author", NamedUser ), - InternalObjectAttribute( "committer", NamedUser ), - ExternalListOfObjects( "comments", "comment", CommitComment, - ListGetable( [], [], __modifyAttributesForObjectsReferingReferedRepo ), - ElementCreatable( [ "body" ], [ "commit_id", "line", "path", "position" ], __modifyAttributesForObjectsReferingReferedRepo ), - ), -) - -Tag = GithubObject( - "Tag", - InternalSimpleAttributes( - "name", "zipball_url", "tarball_url", - "_repo", - ), - InternalObjectAttribute( "commit", Commit ) -) - -Branch = GithubObject( - "Branch", - InternalSimpleAttributes( - "name", - "_repo", - ), - InternalObjectAttribute( "commit", Commit ) -) +from Commit import Commit +from Tag import Tag +from Branch import Branch __modifyAttributesForObjectsReferingRepo = { "_repo": lambda repo: repo } PullRequestFile = GithubObject( diff --git a/github/Tag.py b/github/Tag.py new file mode 100644 index 00000000..c04015da --- /dev/null +++ b/github/Tag.py @@ -0,0 +1,12 @@ +from GithubObject import * + +from Commit import Commit + +Tag = GithubObject( + "Tag", + InternalSimpleAttributes( + "name", "zipball_url", "tarball_url", + "_repo", + ), + InternalObjectAttribute( "commit", Commit ) +)