forked from sigmavirus24/github3.py
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstatus.py
More file actions
90 lines (62 loc) · 2.89 KB
/
Copy pathstatus.py
File metadata and controls
90 lines (62 loc) · 2.89 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# -*- coding: utf-8 -*-
"""
github3.repos.status
====================
This module contains the Status object for GitHub's commit status API
"""
from __future__ import unicode_literals
from .. import users
from ..models import GitHubCore
class Status(GitHubCore):
"""The :class:`Status <Status>` object.
This represents information from the Repo Status API.
See also: http://developer.github.com/v3/repos/statuses/
"""
def _update_attributes(self, status):
#: A string label to differentiate this status from the status of
#: other systems
self.context = self._get_attribute(status, 'context')
#: datetime object representing the creation of the status object
self.created_at = self._strptime_attribute(status, 'created_at')
#: :class:`User <github3.users.User>` who created the object
self.creator = self._class_attribute(
status, 'creator', users.ShortUser
)
#: Short description of the Status
self.description = self._get_attribute(status, 'description')
#: GitHub ID for the status object
self.id = self._get_attribute(status, 'id')
#: State of the status, e.g., 'success', 'pending', 'failed', 'error'
self.state = self._get_attribute(status, 'state')
#: URL to view more information about the status
self.target_url = self._get_attribute(status, 'target_url')
#: datetime object representing the last time the status was updated
self.updated_at = self._strptime_attribute(status, 'updated_at')
def _repr(self):
return '<Status [{s.id}:{s.state}]>'.format(s=self)
class CombinedStatus(GitHubCore):
"""The :class:`CombinedStatus <CombinedStatus>` object.
This represents combined information from the Repo Status API.
See also: http://developer.github.com/v3/repos/statuses/
"""
def _update_attributes(self, combined_status):
#: State of the combined status, e.g., 'success', 'pending', 'failure'
self.state = self._get_attribute(combined_status, 'state')
#: ref's SHA
self.sha = self._get_attribute(combined_status, 'sha')
#: Total count of sub-statuses
self.total_count = self._get_attribute(combined_status, 'total_count')
#: List of :class:`Status <github3.repos.status.Status>`
#: objects.
statuses = self._get_attribute(combined_status, 'statuses', [])
self.statuses = [Status(s) for s in statuses]
from . import Repository
#: Repository the combined status belongs too.
self.repository = self._class_attribute(
combined_status, 'repository', Repository, self
)
#: commit URL
self.commit_url = self._get_attribute(combined_status, 'commit_url')
def _repr(self):
f = '<CombinedStatus [{s.state}:{s.total_count} sub-statuses]>'
return f.format(s=self)