/ github / GistHistoryState.py
GistHistoryState.py
  1  ############################ Copyrights and license ############################
  2  #                                                                              #
  3  # Copyright 2012 Vincent Jacques <vincent@vincent-jacques.net>                 #
  4  # Copyright 2012 Zearin <zearin@gonk.net>                                      #
  5  # Copyright 2013 AKFish <akfish@gmail.com>                                     #
  6  # Copyright 2013 Vincent Jacques <vincent@vincent-jacques.net>                 #
  7  # Copyright 2014 Vincent Jacques <vincent@vincent-jacques.net>                 #
  8  # Copyright 2016 Peter Buckley <dx-pbuckley@users.noreply.github.com>          #
  9  # Copyright 2018 Wan Liuyang <tsfdye@gmail.com>                                #
 10  # Copyright 2018 sfdye <tsfdye@gmail.com>                                      #
 11  #                                                                              #
 12  # This file is part of PyGithub.                                               #
 13  # http://pygithub.readthedocs.io/                                              #
 14  #                                                                              #
 15  # PyGithub is free software: you can redistribute it and/or modify it under    #
 16  # the terms of the GNU Lesser General Public License as published by the Free  #
 17  # Software Foundation, either version 3 of the License, or (at your option)    #
 18  # any later version.                                                           #
 19  #                                                                              #
 20  # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY  #
 21  # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS    #
 22  # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more #
 23  # details.                                                                     #
 24  #                                                                              #
 25  # You should have received a copy of the GNU Lesser General Public License     #
 26  # along with PyGithub. If not, see <http://www.gnu.org/licenses/>.             #
 27  #                                                                              #
 28  ################################################################################
 29  from __future__ import annotations
 30  
 31  from datetime import datetime
 32  from typing import Any
 33  
 34  import github.CommitStats
 35  import github.Gist
 36  import github.GithubObject
 37  import github.NamedUser
 38  from github.GistFile import GistFile
 39  from github.GithubObject import Attribute, CompletableGithubObject, NotSet
 40  
 41  
 42  class GistHistoryState(CompletableGithubObject):
 43      """
 44      This class represents GistHistoryStates
 45      """
 46  
 47      def _initAttributes(self) -> None:
 48          self._change_status: Attribute[github.CommitStats.CommitStats] = NotSet
 49          self._comments: Attribute[int] = NotSet
 50          self._comments_url: Attribute[str] = NotSet
 51          self._commits_url: Attribute[str] = NotSet
 52          self._committed_at: Attribute[datetime] = NotSet
 53          self._created_at: Attribute[datetime] = NotSet
 54          self._description: Attribute[str] = NotSet
 55          self._files: Attribute[dict[str, GistFile]] = NotSet
 56          self._forks: Attribute[list[github.Gist.Gist]] = NotSet
 57          self._forks_url: Attribute[str] = NotSet
 58          self._git_pull_url: Attribute[str] = NotSet
 59          self._git_push_url: Attribute[str] = NotSet
 60          self._history: Attribute[list[GistHistoryState]] = NotSet
 61          self._html_url: Attribute[str] = NotSet
 62          self._id: Attribute[str] = NotSet
 63          self._owner: Attribute[github.NamedUser.NamedUser] = NotSet
 64          self._public: Attribute[bool] = NotSet
 65          self._updated_at: Attribute[datetime] = NotSet
 66          self._url: Attribute[str] = NotSet
 67          self._user: Attribute[github.NamedUser.NamedUser] = NotSet
 68          self._version: Attribute[str] = NotSet
 69  
 70      @property
 71      def change_status(self) -> github.CommitStats.CommitStats:
 72          self._completeIfNotSet(self._change_status)
 73          return self._change_status.value
 74  
 75      @property
 76      def comments(self) -> int:
 77          self._completeIfNotSet(self._comments)
 78          return self._comments.value
 79  
 80      @property
 81      def comments_url(self) -> str:
 82          self._completeIfNotSet(self._comments_url)
 83          return self._comments_url.value
 84  
 85      @property
 86      def commits_url(self) -> str:
 87          self._completeIfNotSet(self._commits_url)
 88          return self._commits_url.value
 89  
 90      @property
 91      def committed_at(self) -> datetime:
 92          self._completeIfNotSet(self._committed_at)
 93          return self._committed_at.value
 94  
 95      @property
 96      def created_at(self) -> datetime:
 97          self._completeIfNotSet(self._created_at)
 98          return self._created_at.value
 99  
100      @property
101      def description(self) -> str:
102          self._completeIfNotSet(self._description)
103          return self._description.value
104  
105      @property
106      def files(self) -> dict[str, GistFile]:
107          self._completeIfNotSet(self._files)
108          return self._files.value
109  
110      @property
111      def forks(self) -> list[github.Gist.Gist]:
112          self._completeIfNotSet(self._forks)
113          return self._forks.value
114  
115      @property
116      def forks_url(self) -> str:
117          self._completeIfNotSet(self._forks_url)
118          return self._forks_url.value
119  
120      @property
121      def git_pull_url(self) -> str:
122          self._completeIfNotSet(self._git_pull_url)
123          return self._git_pull_url.value
124  
125      @property
126      def git_push_url(self) -> str:
127          self._completeIfNotSet(self._git_push_url)
128          return self._git_push_url.value
129  
130      @property
131      def history(self) -> list[GistHistoryState]:
132          self._completeIfNotSet(self._history)
133          return self._history.value
134  
135      @property
136      def html_url(self) -> str:
137          self._completeIfNotSet(self._html_url)
138          return self._html_url.value
139  
140      @property
141      def id(self) -> str:
142          self._completeIfNotSet(self._id)
143          return self._id.value
144  
145      @property
146      def owner(self) -> github.NamedUser.NamedUser:
147          self._completeIfNotSet(self._owner)
148          return self._owner.value
149  
150      @property
151      def public(self) -> bool:
152          self._completeIfNotSet(self._public)
153          return self._public.value
154  
155      @property
156      def updated_at(self) -> datetime:
157          self._completeIfNotSet(self._updated_at)
158          return self._updated_at.value
159  
160      @property
161      def url(self) -> str:
162          self._completeIfNotSet(self._url)
163          return self._url.value
164  
165      @property
166      def user(self) -> github.NamedUser.NamedUser:
167          self._completeIfNotSet(self._user)
168          return self._user.value
169  
170      @property
171      def version(self) -> str:
172          self._completeIfNotSet(self._version)
173          return self._version.value
174  
175      def _useAttributes(self, attributes: dict[str, Any]) -> None:
176          if "change_status" in attributes:  # pragma no branch
177              self._change_status = self._makeClassAttribute(github.CommitStats.CommitStats, attributes["change_status"])
178          if "comments" in attributes:  # pragma no branch
179              self._comments = self._makeIntAttribute(attributes["comments"])
180          if "comments_url" in attributes:  # pragma no branch
181              self._comments_url = self._makeStringAttribute(attributes["comments_url"])
182          if "commits_url" in attributes:  # pragma no branch
183              self._commits_url = self._makeStringAttribute(attributes["commits_url"])
184          if "committed_at" in attributes:  # pragma no branch
185              self._committed_at = self._makeDatetimeAttribute(attributes["committed_at"])
186          if "created_at" in attributes:  # pragma no branch
187              self._created_at = self._makeDatetimeAttribute(attributes["created_at"])
188          if "description" in attributes:  # pragma no branch
189              self._description = self._makeStringAttribute(attributes["description"])
190          if "files" in attributes:  # pragma no branch
191              self._files = self._makeDictOfStringsToClassesAttribute(github.GistFile.GistFile, attributes["files"])
192          if "forks" in attributes:  # pragma no branch
193              self._forks = self._makeListOfClassesAttribute(github.Gist.Gist, attributes["forks"])
194          if "forks_url" in attributes:  # pragma no branch
195              self._forks_url = self._makeStringAttribute(attributes["forks_url"])
196          if "git_pull_url" in attributes:  # pragma no branch
197              self._git_pull_url = self._makeStringAttribute(attributes["git_pull_url"])
198          if "git_push_url" in attributes:  # pragma no branch
199              self._git_push_url = self._makeStringAttribute(attributes["git_push_url"])
200          if "history" in attributes:  # pragma no branch
201              self._history = self._makeListOfClassesAttribute(GistHistoryState, attributes["history"])
202          if "html_url" in attributes:  # pragma no branch
203              self._html_url = self._makeStringAttribute(attributes["html_url"])
204          if "id" in attributes:  # pragma no branch
205              self._id = self._makeStringAttribute(attributes["id"])
206          if "owner" in attributes:  # pragma no branch
207              self._owner = self._makeClassAttribute(github.NamedUser.NamedUser, attributes["owner"])
208          if "public" in attributes:  # pragma no branch
209              self._public = self._makeBoolAttribute(attributes["public"])
210          if "updated_at" in attributes:  # pragma no branch
211              self._updated_at = self._makeDatetimeAttribute(attributes["updated_at"])
212          if "url" in attributes:  # pragma no branch
213              self._url = self._makeStringAttribute(attributes["url"])
214          if "user" in attributes:  # pragma no branch
215              self._user = self._makeClassAttribute(github.NamedUser.NamedUser, attributes["user"])
216          if "version" in attributes:  # pragma no branch
217              self._version = self._makeStringAttribute(attributes["version"])