1# -*- coding: utf-8 -*- 2 3############################ Copyrights and license ############################ 4# # 5# Copyright 2012 Vincent Jacques <vincent@vincent-jacques.net> # 6# Copyright 2012 Zearin <zearin@gonk.net> # 7# Copyright 2013 AKFish <akfish@gmail.com> # 8# Copyright 2013 Vincent Jacques <vincent@vincent-jacques.net> # 9# Copyright 2014 Vincent Jacques <vincent@vincent-jacques.net> # 10# Copyright 2016 Peter Buckley <dx-pbuckley@users.noreply.github.com> # 11# Copyright 2018 Wan Liuyang <tsfdye@gmail.com> # 12# Copyright 2018 sfdye <tsfdye@gmail.com> # 13# # 14# This file is part of PyGithub. # 15# http://pygithub.readthedocs.io/ # 16# # 17# PyGithub is free software: you can redistribute it and/or modify it under # 18# the terms of the GNU Lesser General Public License as published by the Free # 19# Software Foundation, either version 3 of the License, or (at your option) # 20# any later version. # 21# # 22# PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # 23# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # 24# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # 25# details. # 26# # 27# You should have received a copy of the GNU Lesser General Public License # 28# along with PyGithub. If not, see <http://www.gnu.org/licenses/>. # 29# # 30################################################################################ 31 32import github.Commit 33import github.File 34import github.GithubObject 35 36 37class Comparison(github.GithubObject.CompletableGithubObject): 38 """ 39 This class represents Comparisons 40 """ 41 42 @property 43 def ahead_by(self): 44 """ 45 :type: integer 46 """ 47 self._completeIfNotSet(self._ahead_by) 48 return self._ahead_by.value 49 50 @property 51 def base_commit(self): 52 """ 53 :type: :class:`github.Commit.Commit` 54 """ 55 self._completeIfNotSet(self._base_commit) 56 return self._base_commit.value 57 58 @property 59 def behind_by(self): 60 """ 61 :type: integer 62 """ 63 self._completeIfNotSet(self._behind_by) 64 return self._behind_by.value 65 66 @property 67 def commits(self): 68 """ 69 :type: list of :class:`github.Commit.Commit` 70 """ 71 self._completeIfNotSet(self._commits) 72 return self._commits.value 73 74 @property 75 def diff_url(self): 76 """ 77 :type: string 78 """ 79 self._completeIfNotSet(self._diff_url) 80 return self._diff_url.value 81 82 @property 83 def files(self): 84 """ 85 :type: list of :class:`github.File.File` 86 """ 87 self._completeIfNotSet(self._files) 88 return self._files.value 89 90 @property 91 def html_url(self): 92 """ 93 :type: string 94 """ 95 self._completeIfNotSet(self._html_url) 96 return self._html_url.value 97 98 @property 99 def merge_base_commit(self): 100 """ 101 :type: :class:`github.Commit.Commit` 102 """ 103 self._completeIfNotSet(self._merge_base_commit) 104 return self._merge_base_commit.value 105 106 @property 107 def patch_url(self): 108 """ 109 :type: string 110 """ 111 self._completeIfNotSet(self._patch_url) 112 return self._patch_url.value 113 114 @property 115 def permalink_url(self): 116 """ 117 :type: string 118 """ 119 self._completeIfNotSet(self._permalink_url) 120 return self._permalink_url.value 121 122 @property 123 def status(self): 124 """ 125 :type: string 126 """ 127 self._completeIfNotSet(self._status) 128 return self._status.value 129 130 @property 131 def total_commits(self): 132 """ 133 :type: integer 134 """ 135 self._completeIfNotSet(self._total_commits) 136 return self._total_commits.value 137 138 @property 139 def url(self): 140 """ 141 :type: string 142 """ 143 self._completeIfNotSet(self._url) 144 return self._url.value 145 146 def _initAttributes(self): 147 self._ahead_by = github.GithubObject.NotSet 148 self._base_commit = github.GithubObject.NotSet 149 self._behind_by = github.GithubObject.NotSet 150 self._commits = github.GithubObject.NotSet 151 self._diff_url = github.GithubObject.NotSet 152 self._files = github.GithubObject.NotSet 153 self._html_url = github.GithubObject.NotSet 154 self._merge_base_commit = github.GithubObject.NotSet 155 self._patch_url = github.GithubObject.NotSet 156 self._permalink_url = github.GithubObject.NotSet 157 self._status = github.GithubObject.NotSet 158 self._total_commits = github.GithubObject.NotSet 159 self._url = github.GithubObject.NotSet 160 161 def _useAttributes(self, attributes): 162 if "ahead_by" in attributes: # pragma no branch 163 self._ahead_by = self._makeIntAttribute(attributes["ahead_by"]) 164 if "base_commit" in attributes: # pragma no branch 165 self._base_commit = self._makeClassAttribute( 166 github.Commit.Commit, attributes["base_commit"] 167 ) 168 if "behind_by" in attributes: # pragma no branch 169 self._behind_by = self._makeIntAttribute(attributes["behind_by"]) 170 if "commits" in attributes: # pragma no branch 171 self._commits = self._makeListOfClassesAttribute( 172 github.Commit.Commit, attributes["commits"] 173 ) 174 if "diff_url" in attributes: # pragma no branch 175 self._diff_url = self._makeStringAttribute(attributes["diff_url"]) 176 if "files" in attributes: # pragma no branch 177 self._files = self._makeListOfClassesAttribute( 178 github.File.File, attributes["files"] 179 ) 180 if "html_url" in attributes: # pragma no branch 181 self._html_url = self._makeStringAttribute(attributes["html_url"]) 182 if "merge_base_commit" in attributes: # pragma no branch 183 self._merge_base_commit = self._makeClassAttribute( 184 github.Commit.Commit, attributes["merge_base_commit"] 185 ) 186 if "patch_url" in attributes: # pragma no branch 187 self._patch_url = self._makeStringAttribute(attributes["patch_url"]) 188 if "permalink_url" in attributes: # pragma no branch 189 self._permalink_url = self._makeStringAttribute(attributes["permalink_url"]) 190 if "status" in attributes: # pragma no branch 191 self._status = self._makeStringAttribute(attributes["status"]) 192 if "total_commits" in attributes: # pragma no branch 193 self._total_commits = self._makeIntAttribute(attributes["total_commits"]) 194 if "url" in attributes: # pragma no branch 195 self._url = self._makeStringAttribute(attributes["url"]) 196