/ github / Topic.py
Topic.py
  1  ############################ Copyrights and license ############################
  2  #                                                                              #
  3  # Copyright 2018 Steve Kowalik <steven@wedontsleep.org>                        #
  4  #                                                                              #
  5  # This file is part of PyGithub.                                               #
  6  # http://pygithub.readthedocs.io/                                              #
  7  #                                                                              #
  8  # PyGithub is free software: you can redistribute it and/or modify it under    #
  9  # the terms of the GNU Lesser General Public License as published by the Free  #
 10  # Software Foundation, either version 3 of the License, or (at your option)    #
 11  # any later version.                                                           #
 12  #                                                                              #
 13  # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY  #
 14  # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS    #
 15  # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more #
 16  # details.                                                                     #
 17  #                                                                              #
 18  # You should have received a copy of the GNU Lesser General Public License     #
 19  # along with PyGithub. If not, see <http://www.gnu.org/licenses/>.             #
 20  #                                                                              #
 21  ################################################################################
 22  from __future__ import annotations
 23  
 24  from datetime import datetime
 25  from typing import Any
 26  
 27  from github.GithubObject import Attribute, NonCompletableGithubObject, NotSet
 28  
 29  
 30  class Topic(NonCompletableGithubObject):
 31      """
 32      This class represents topics as used by https://github.com/topics. The object reference can be found here https://docs.github.com/en/rest/reference/search#search-topics
 33      """
 34  
 35      def _initAttributes(self) -> None:
 36          self._name: Attribute[str] = NotSet
 37          self._display_name: Attribute[str] = NotSet
 38          self._short_description: Attribute[str] = NotSet
 39          self._description: Attribute[str] = NotSet
 40          self._created_by: Attribute[str] = NotSet
 41          self._released: Attribute[str] = NotSet
 42          self._created_at: Attribute[datetime] = NotSet
 43          self._updated_at: Attribute[datetime] = NotSet
 44          self._featured: Attribute[bool] = NotSet
 45          self._curated: Attribute[bool] = NotSet
 46          self._score: Attribute[float] = NotSet
 47  
 48      def __repr__(self) -> str:
 49          return self.get__repr__({"name": self._name.value})
 50  
 51      @property
 52      def name(self) -> str:
 53          return self._name.value
 54  
 55      @property
 56      def display_name(self) -> str:
 57          return self._display_name.value
 58  
 59      @property
 60      def short_description(self) -> str:
 61          return self._short_description.value
 62  
 63      @property
 64      def description(self) -> str:
 65          return self._description.value
 66  
 67      @property
 68      def created_by(self) -> str:
 69          return self._created_by.value
 70  
 71      @property
 72      def released(self) -> str:
 73          return self._released.value
 74  
 75      @property
 76      def created_at(self) -> datetime:
 77          return self._created_at.value
 78  
 79      @property
 80      def updated_at(self) -> datetime:
 81          return self._updated_at.value
 82  
 83      @property
 84      def featured(self) -> bool:
 85          return self._featured.value
 86  
 87      @property
 88      def curated(self) -> bool:
 89          return self._curated.value
 90  
 91      @property
 92      def score(self) -> float:
 93          return self._score.value
 94  
 95      def _useAttributes(self, attributes: dict[str, Any]) -> None:
 96          if "name" in attributes:  # pragma no branch
 97              self._name = self._makeStringAttribute(attributes["name"])
 98          if "display_name" in attributes:  # pragma no branch
 99              self._display_name = self._makeStringAttribute(attributes["display_name"])
100          if "short_description" in attributes:  # pragma no branch
101              self._short_description = self._makeStringAttribute(attributes["short_description"])
102          if "description" in attributes:  # pragma no branch
103              self._description = self._makeStringAttribute(attributes["description"])
104          if "created_by" in attributes:  # pragma no branch
105              self._created_by = self._makeStringAttribute(attributes["created_by"])
106          if "released" in attributes:  # pragma no branch
107              self._released = self._makeStringAttribute(attributes["released"])
108          if "created_at" in attributes:  # pragma no branch
109              self._created_at = self._makeDatetimeAttribute(attributes["created_at"])
110          if "updated_at" in attributes:  # pragma no branch
111              self._updated_at = self._makeDatetimeAttribute(attributes["updated_at"])
112          if "featured" in attributes:  # pragma no branch
113              self._featured = self._makeBoolAttribute(attributes["featured"])
114          if "curated" in attributes:  # pragma no branch
115              self._curated = self._makeBoolAttribute(attributes["curated"])
116          if "score" in attributes:  # pragma no branch
117              self._score = self._makeFloatAttribute(attributes["score"])