/ github / Path.py
Path.py
 1  ############################ Copyrights and license ############################
 2  #                                                                              #
 3  # Copyright 2018 Justin Kufro <jkufro@andrew.cmu.edu>                          #
 4  # Copyright 2018 Ivan Minno <iminno@andrew.cmu.edu>                            #
 5  # Copyright 2018 Zilei Gu <zileig@andrew.cmu.edu>                              #
 6  # Copyright 2018 Yves Zumbach <yzumbach@andrew.cmu.edu>                        #
 7  # Copyright 2018 Leying Chen <leyingc@andrew.cmu.edu>                          #
 8  #                                                                              #
 9  # This file is part of PyGithub.                                               #
10  # http://pygithub.readthedocs.io/                                              #
11  #                                                                              #
12  # PyGithub is free software: you can redistribute it and/or modify it under    #
13  # the terms of the GNU Lesser General Public License as published by the Free  #
14  # Software Foundation, either version 3 of the License, or (at your option)    #
15  # any later version.                                                           #
16  #                                                                              #
17  # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY  #
18  # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS    #
19  # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more #
20  # details.                                                                     #
21  #                                                                              #
22  # You should have received a copy of the GNU Lesser General Public License     #
23  # along with PyGithub. If not, see <http://www.gnu.org/licenses/>.             #
24  #                                                                              #
25  ################################################################################
26  from typing import Any, Dict
27  
28  from github.GithubObject import Attribute, NonCompletableGithubObject, NotSet
29  
30  
31  class Path(NonCompletableGithubObject):
32      """
33      This class represents a popular Path for a GitHub repository.
34      The reference can be found here https://docs.github.com/en/rest/reference/repos#traffic
35      """
36  
37      def _initAttributes(self) -> None:
38          self._path: Attribute[str] = NotSet
39          self._title: Attribute[str] = NotSet
40          self._count: Attribute[int] = NotSet
41          self._uniques: Attribute[int] = NotSet
42  
43      def __repr__(self) -> str:
44          return self.get__repr__(
45              {
46                  "path": self._path.value,
47                  "title": self._title.value,
48                  "count": self._count.value,
49                  "uniques": self._uniques.value,
50              }
51          )
52  
53      @property
54      def path(self) -> str:
55          return self._path.value
56  
57      @property
58      def title(self) -> str:
59          return self._title.value
60  
61      @property
62      def count(self) -> int:
63          return self._count.value
64  
65      @property
66      def uniques(self) -> int:
67          return self._uniques.value
68  
69      def _useAttributes(self, attributes: Dict[str, Any]) -> None:
70          if "path" in attributes:  # pragma no branch
71              self._path = self._makeStringAttribute(attributes["path"])
72          if "title" in attributes:  # pragma no branch
73              self._title = self._makeStringAttribute(attributes["title"])
74          if "count" in attributes:  # pragma no branch
75              self._count = self._makeIntAttribute(attributes["count"])
76          if "uniques" in attributes:  # pragma no branch
77              self._uniques = self._makeIntAttribute(attributes["uniques"])