GitignoreTemplate.py
1 ############################ Copyrights and license ############################ 2 # # 3 # Copyright 2012 Vincent Jacques <vincent@vincent-jacques.net> # 4 # Copyright 2013 AKFish <akfish@gmail.com> # 5 # Copyright 2013 Vincent Jacques <vincent@vincent-jacques.net> # 6 # Copyright 2014 Vincent Jacques <vincent@vincent-jacques.net> # 7 # Copyright 2016 Jannis Gebauer <ja.geb@me.com> # 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 30 from typing import Any, Dict 31 32 from github.GithubObject import Attribute, NonCompletableGithubObject, NotSet 33 34 35 class GitignoreTemplate(NonCompletableGithubObject): 36 """ 37 This class represents GitignoreTemplates. The reference can be found here https://docs.github.com/en/rest/reference/gitignore 38 """ 39 40 def _initAttributes(self) -> None: 41 self._source: Attribute[str] = NotSet 42 self._name: Attribute[str] = NotSet 43 44 def __repr__(self) -> str: 45 return self.get__repr__({"name": self._name.value}) 46 47 @property 48 def source(self) -> str: 49 return self._source.value 50 51 @property 52 def name(self) -> str: 53 return self._name.value 54 55 def _useAttributes(self, attributes: Dict[str, Any]) -> None: 56 if "source" in attributes: # pragma no branch 57 self._source = self._makeStringAttribute(attributes["source"]) 58 if "name" in attributes: # pragma no branch 59 self._name = self._makeStringAttribute(attributes["name"])