1# -*- coding: utf-8 -*-
2
3############################ Copyrights and license ############################
4#                                                                              #
5# Copyright 2012 Vincent Jacques <vincent@vincent-jacques.net>                 #
6# Copyright 2012 Zearin <zearin@gonk.net>                                      #
7# Copyright 2013 AKFish <akfish@gmail.com>                                     #
8# Copyright 2013 Vincent Jacques <vincent@vincent-jacques.net>                 #
9# Copyright 2014 Vincent Jacques <vincent@vincent-jacques.net>                 #
10# Copyright 2016 Jannis Gebauer <ja.geb@me.com>                                #
11# Copyright 2016 Peter Buckley <dx-pbuckley@users.noreply.github.com>          #
12# Copyright 2018 Wan Liuyang <tsfdye@gmail.com>                                #
13# Copyright 2018 sfdye <tsfdye@gmail.com>                                      #
14#                                                                              #
15# This file is part of PyGithub.                                               #
16# http://pygithub.readthedocs.io/                                              #
17#                                                                              #
18# PyGithub is free software: you can redistribute it and/or modify it under    #
19# the terms of the GNU Lesser General Public License as published by the Free  #
20# Software Foundation, either version 3 of the License, or (at your option)    #
21# any later version.                                                           #
22#                                                                              #
23# PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY  #
24# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS    #
25# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more #
26# details.                                                                     #
27#                                                                              #
28# You should have received a copy of the GNU Lesser General Public License     #
29# along with PyGithub. If not, see <http://www.gnu.org/licenses/>.             #
30#                                                                              #
31################################################################################
32
33import github.GithubObject
34
35
36class GitObject(github.GithubObject.NonCompletableGithubObject):
37    """
38    This class represents GitObjects
39    """
40
41    def __repr__(self):
42        return self.get__repr__({"sha": self._sha.value})
43
44    @property
45    def sha(self):
46        """
47        :type: string
48        """
49        return self._sha.value
50
51    @property
52    def type(self):
53        """
54        :type: string
55        """
56        return self._type.value
57
58    @property
59    def url(self):
60        """
61        :type: string
62        """
63        return self._url.value
64
65    def _initAttributes(self):
66        self._sha = github.GithubObject.NotSet
67        self._type = github.GithubObject.NotSet
68        self._url = github.GithubObject.NotSet
69
70    def _useAttributes(self, attributes):
71        if "sha" in attributes:  # pragma no branch
72            self._sha = self._makeStringAttribute(attributes["sha"])
73        if "type" in attributes:  # pragma no branch
74            self._type = self._makeStringAttribute(attributes["type"])
75        if "url" in attributes:  # pragma no branch
76            self._url = self._makeStringAttribute(attributes["url"])
77