forked from sigmavirus24/github3.py
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhistory.py
More file actions
68 lines (45 loc) · 1.77 KB
/
Copy pathhistory.py
File metadata and controls
68 lines (45 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# -*- coding: utf-8 -*-
"""
github3.gists.history
---------------------
Module containing the logic for the GistHistory object.
"""
from __future__ import unicode_literals
from ..models import GitHubCore
from ..users import User
class GistHistory(GitHubCore):
"""Thisobject represents one version (or revision) of a gist.
Two history instances can be checked like so::
h1 == h2
h1 != h2
And is equivalent to::
h1.version == h2.version
h1.version != h2.version
"""
def __init__(self, history, session=None):
super(GistHistory, self).__init__(history, session)
self._api = history.get('url', '')
#: SHA of the commit associated with this version
self.version = history.get('version', '')
#: user who made these changes
self.user = User(history.get('user') or {}, session)
#: dict containing the change status; see also: deletions, additions,
#: total
self.change_status = history.get('change_status', {})
#: number of additions made
self.additions = self.change_status.get('additions', 0)
#: number of deletions made
self.deletions = self.change_status.get('deletions', 0)
#: total number of changes made
self.total = self.change_status.get('total', 0)
#: datetime representation of when the commit was made
self.committed_at = self._strptime(history.get('committed_at'))
def _repr(self):
return '<Gist History [{0}]>'.format(self.version)
def get_gist(self):
"""Retrieve the gist at this version.
:returns: :class:`Gist <github3.gists.gist.Gist>`
"""
from .gist import Gist
json = self._json(self._get(self._api), 200)
return Gist(json, self)