/ github / Tag.py
Tag.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 2013 martinqt <m.ki2@laposte.net>                                  #
 8  # Copyright 2014 Vincent Jacques <vincent@vincent-jacques.net>                 #
 9  # Copyright 2016 Jannis Gebauer <ja.geb@me.com>                                #
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  from __future__ import annotations
32  
33  from typing import TYPE_CHECKING, Any
34  
35  import github.Commit
36  from github.GithubObject import Attribute, NonCompletableGithubObject, NotSet
37  
38  if TYPE_CHECKING:
39      from github.Commit import Commit
40  
41  
42  class Tag(NonCompletableGithubObject):
43      """
44      This class represents Tags. The reference can be found here https://docs.github.com/en/rest/reference/repos#list-repository-tags
45      """
46  
47      def __repr__(self) -> str:
48          return self.get__repr__({"name": self._name.value, "commit": self._commit.value})
49  
50      def _initAttributes(self) -> None:
51          self._commit: Attribute[Commit] = NotSet
52          self._name: Attribute[str] = NotSet
53          self._tarball_url: Attribute[str] = NotSet
54          self._zipball_url: Attribute[str] = NotSet
55  
56      @property
57      def commit(self) -> Commit:
58          return self._commit.value
59  
60      @property
61      def name(self) -> str:
62          return self._name.value
63  
64      @property
65      def tarball_url(self) -> str:
66          return self._tarball_url.value
67  
68      @property
69      def zipball_url(self) -> str:
70          return self._zipball_url.value
71  
72      def _useAttributes(self, attributes: dict[str, Any]) -> None:
73          if "commit" in attributes:  # pragma no branch
74              self._commit = self._makeClassAttribute(github.Commit.Commit, attributes["commit"])
75          if "name" in attributes:  # pragma no branch
76              self._name = self._makeStringAttribute(attributes["name"])
77          if "tarball_url" in attributes:  # pragma no branch
78              self._tarball_url = self._makeStringAttribute(attributes["tarball_url"])
79          if "zipball_url" in attributes:  # pragma no branch
80              self._zipball_url = self._makeStringAttribute(attributes["zipball_url"])