8000 Update git module · staticdev/github4.py@2f066e6 · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on May 22, 2021. It is now read-only.

Commit 2f066e6

Browse files
committed
Update git module
1 parent 7f85917 commit 2f066e6

File tree

1 file changed

+9
-21
lines changed

1 file changed

+9
-21
lines changed

github3/git.py

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ class Blob(GitHubObject):
2424
2525
"""
2626

27-
def __init__(self, blob):
28-
super(Blob, self).__init__(blob)
27+
def _update_attributes(self, blob):
2928
self._api = blob.get('url', '')
3029

3130
#: Raw content of the blob.
@@ -56,8 +55,7 @@ class GitData(GitHubCore):
5655
5756
"""
5857

59-
def __init__(self, data, session=None):
60-
super(GitData, self).__init__(data, session)
58+
def _update_attributes(self, data):
6159
#: SHA of the object
6260
self.sha = data.get('sha')
6361
self._api = data.get('url', '')
@@ -72,9 +70,7 @@ class Commit(BaseCommit):
7270
7371
"""
7472

75-
def __init__(self, commit, session=None):
76-
super(Commit, self).__init__(commit, session)
77-
73+
def _update_attributes(self, commit):
7874
#: dict containing at least the name, email and date the commit was
7975
#: created
8076
self.author = commit.get('author', {}) or {}
@@ -121,8 +117,7 @@ class Reference(GitHubCore):
121117
122118
"""
123119

124-
def __init__(self, ref, session=None):
125-
super(Reference, self).__init__(ref, session)
120+
def _update_attributes(self, ref):
126121
self._api = ref.get('url', '')
127122
#: The reference path, e.g., refs/heads/sc/featureA
128123
self.ref = ref.get('ref')
@@ -132,9 +127,6 @@ def __init__(self, ref, session=None):
132127
def _repr(self):
133128
return '<Reference [{0}]>'.format(self.ref)
134129

135-
def _update_(self, ref):
136-
self.__init__(ref, self.session)
137-
138130
@requires_auth
139131
def delete(self):
140132
"""Delete this reference.
@@ -156,7 +148,7 @@ def update(self, sha, force=False):
156148
data = {'sha': sha, 'force': force}
157149
json = self._json(self._patch(self._api, data=dumps(data)), 200)
158150
if json:
159-
self._update_(json)
151+
self._update_attributes(json)
160152
return True
161153
return False
162154

@@ -165,8 +157,7 @@ class GitObject(GitData):
165157

166158
"""The :class:`GitObject <GitObject>` object."""
167159

168-
def __init__(self, obj):
169-
super(GitObject, self).__init__(obj, None)
160+
def _update_attributes(self, obj):
170161
#: The type of object.
171162
self.type = obj.get('type')
172163

@@ -182,8 +173,7 @@ class Tag(GitData):
182173
183174
"""
184175

185-
def __init__(self, tag):
186-
super(Tag, self).__init__(tag, None)
176+
def _update_attributes(self, tag):
187177
#: String of the tag
188178
self.tag = tag.get('tag')
189179
#: Commit message for the tag
@@ -205,8 +195,7 @@ class Tree(GitData):
205195
206196
"""
207197

208-
def __init__(self, tree, session=None):
209-
super(Tree, self).__init__(tree, session)
198+
def _update_attributes(self, tree):
210199
#: list of :class:`Hash <Hash>` objects
211200
self.tree = [Hash(t) for t in tree.get('tree', [])]
212201

@@ -231,8 +220,7 @@ class Hash(GitHubObject):
231220
232221
"""
233222

234-
def __init__(self, info):
235-
super(Hash, self).__init__(info)
223+
def _update_attribute(self, info):
236224
#: Path to file
237225
self.path = info.get('path')
238226
#: File mode

0 commit comments

Comments
 (0)
0