/ github / Permissions.py
Permissions.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 Jannis Gebauer <ja.geb@me.com>                                #
 9  # Copyright 2016 Peter Buckley <dx-pbuckley@users.noreply.github.com>          #
10  # Copyright 2018 Wan Liuyang <tsfdye@gmail.com>                                #
11  # Copyright 2018 sfdye <tsfdye@gmail.com>                                      #
12  #                                                                              #
13  # This file is part of PyGithub.                                               #
14  # http://pygithub.readthedocs.io/                                              #
15  #                                                                              #
16  # PyGithub is free software: you can redistribute it and/or modify it under    #
17  # the terms of the GNU Lesser General Public License as published by the Free  #
18  # Software Foundation, either version 3 of the License, or (at your option)    #
19  # any later version.                                                           #
20  #                                                                              #
21  # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY  #
22  # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS    #
23  # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more #
24  # details.                                                                     #
25  #                                                                              #
26  # You should have received a copy of the GNU Lesser General Public License     #
27  # along with PyGithub. If not, see <http://www.gnu.org/licenses/>.             #
28  #                                                                              #
29  ################################################################################
30  from typing import Any, Dict
31  
32  from github.GithubObject import Attribute, NonCompletableGithubObject, NotSet
33  
34  
35  class Permissions(NonCompletableGithubObject):
36      """
37      This class represents Permissions
38      """
39  
40      def _initAttributes(self) -> None:
41          self._admin: Attribute[bool] = NotSet
42          self._maintain: Attribute[bool] = NotSet
43          self._pull: Attribute[bool] = NotSet
44          self._push: Attribute[bool] = NotSet
45          self._triage: Attribute[bool] = NotSet
46  
47      def __repr__(self) -> str:
48          return self.get__repr__(
49              {
50                  "admin": self._admin.value,
51                  "maintain": self._maintain.value,
52                  "pull": self._pull.value,
53                  "push": self._push.value,
54                  "triage": self._triage.value,
55              }
56          )
57  
58      @property
59      def admin(self) -> bool:
60          return self._admin.value
61  
62      @property
63      def maintain(self) -> bool:
64          return self._maintain.value
65  
66      @property
67      def pull(self) -> bool:
68          return self._pull.value
69  
70      @property
71      def push(self) -> bool:
72          return self._push.value
73  
74      @property
75      def triage(self) -> bool:
76          return self._triage.value
77  
78      def _useAttributes(self, attributes: Dict[str, Any]) -> None:
79          if "admin" in attributes:  # pragma no branch
80              self._admin = self._makeBoolAttribute(attributes["admin"])
81          if "maintain" in attributes:  # pragma no branch
82              self._maintain = self._makeBoolAttribute(attributes["maintain"])
83          if "pull" in attributes:  # pragma no branch
84              self._pull = self._makeBoolAttribute(attributes["pull"])
85          if "push" in attributes:  # pragma no branch
86              self._push = self._makeBoolAttribute(attributes["push"])
87          if "triage" in attributes:  # pragma no branch
88              self._triage = self._makeBoolAttribute(attributes["triage"])