8000 Update github3.repos.hook for consistency · domdfcoding/github3.py@232cff2 · GitHub
[go: up one dir, main page]

Skip to content

Commit 232cff2

Browse files
committed
Update github3.repos.hook for consistency
1 parent f7748b6 commit 232cff2

File tree

1 file changed

+64
-47
lines changed

1 file changed

+64
-47
lines changed

github3/repos/hook.py

Lines changed: 64 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
# -*- coding: utf-8 -*-
2-
"""
3-
github3.repos.hook
4-
==================
5-
6-
This module contains only the Hook object for GitHub's Hook API.
7-
8-
"""
2+
"""This module contains only the Hook object for GitHub's Hook API."""
93
from __future__ import unicode_literals
104

115
from json import dumps
@@ -14,44 +8,52 @@
148

159

1610
class Hook(GitHubCore):
17-
"""The :class:`Hook <Hook>` object. This handles the information returned
18-
by GitHub about hooks set on a repository.
11+
"""The representation of a hook on a repository.
1912
20-
Two hook instances can be checked like so::
13+
See also: http://developer.github.com/v3/repos/hooks/
2114
22-
h1 == h2
23-
h1 != h2
15+
This object has the following attributes:
2416
25-
And is equivalent to::
17+
.. attribute:: active
2618
27-
h1.id == h2.id
28-
h1.id != h2.id
19+
A boolean attribute describing whether the hook is active or not.
2920
30-
See also: http://developer.github.com/v3/repos/hooks/
31-
"""
32-
def _update_attributes(self, hook, session=None):
33-
self._api = self._get_attribute(hook, 'url')
21+
.. attribute:: config
22+
23+
A dictionary containing the configuration for this hook.
3424
35-
#: datetime object representing when this hook was last updated.
36-
self.updated_at = self._strptime_attribute(hook, 'updated_at')
25+
.. attribute:: created_at
3726
38-
#: datetime object representing the date the hook was created.
39-
self.created_at = self._strptime_attribute(hook, 'created_at')
27+
A :class:`~datetime.datetime` object representing the date and time
28+
when this hook was created.
4029
41-
#: The name of the hook.
42-
self.name = self._get_attribute(hook, 'name')
30+
.. attribute:: events
4331
44-
#: Events which trigger the hook.
45-
self.events = self._get_attribute(hook, 'events')
32+
The list of events which trigger this hook.
4633
47-
#: Whether or not this Hook is marked as active on GitHub
48-
self.active = self._get_attribute(hook, 'active')
34+
.. attribute:: id
4935
50-
#: Dictionary containing the configuration for the Hook.
51-
self.config = self._get_attribute(hook, 'config')
36+
The unique identifier for this hook.
5237
53-
#: Unique id of the hook.
54-
self.id = self._get_attribute(hook, 'id')
38+
.. attribute:: name
39+
40+
The name provided to this hook.
41+
42+
.. attribute:: updated_at
43+
44+
A :class:`~datetime.datetime` object representing the date and time
45+
when this hook was updated.
46+
"""
47+
48+
def _update_attributes(self, hook, session=None):
49+
self._api = hook['url']
50+
self.active = hook['active']
51+
self.config = hook['config']
52+
self.created_at = self._strptime(hook['created_at'])
53+
self.events = hook['events']
54+
self.id = hook['id']
55+
self.name = hook['name']
56+
self.updated_at = self._strptime(hook['updated_at'])
5557

5658
def _repr(self):
5759
return '<Hook [{0}]>'.format(self.name)
@@ -60,7 +62,10 @@ def _repr(self):
6062
def delete(self):
6163
"""Delete this hook.
6264
63-
:returns: bool
65+
:returns:
66+
True if successful, False otherwise
67+
:rtype:
68+
bool
6469
"""
6570
return self._boolean(self._delete(self._api), 204, 404)
6671

@@ -69,16 +74,22 @@ def edit(self, config={}, events=[], add_events=[], rm_events=[],
6974
active=True):
7075
"""Edit this hook.
7176
72-
:param dict config: (optional), key-value pairs of settings for this
73-
hook
74-
:param list events: (optional), which events should this be triggered
75-
for
76-
:param list add_events: (optional), events to be added to the list of
77-
events that this hook triggers for
78-
:param list rm_events: (optional), events to be removed from the list
79-
of events that this hook triggers for
80-
:param bool active: (optional), should this event be active
81-
:returns: bool
77+
:param dict config:
78+
(optional), key-value pairs of settings for this hook
79+
:param list events:
80+
(optional), which events should this be triggered for
81+
:param list add_events:
82+
(optional), events to be added to the list of events that this hook
83+
triggers for
84+
:param list rm_events:
85+
(optional), events to be removed from the list of events that this
86+
hook triggers for
87+
:param bool active:
88+
(optional), should this event be active
89+
:returns:
90+
True if successful, False otherwise
91+
:rtype:
92+
bool
8293
"""
8394
data = {'config': config, 'active': active}
8495
if events:
@@ -102,16 +113,22 @@ def edit(self, config={}, events=[], add_events=[], rm_events=[],
102113
def ping(self):
103114
"""Ping this hook.
104115
105-
:returns: bool
116+
:returns:
117+
True if successful, False otherwise
118+
:rtype:
119+
bool
106120
"""
107121
url = self._build_url('pings', base_url=self._api)
108122
return self._boolean(self._post(url), 204, 404)
109123

110124
@requires_auth
111125
def test(self):
112-
"""Test this hook
126+
"""Test this hook.
113127
114-
:returns: bool
128+
:returns:
129+
True if successful, False otherwise
130+
:rtype:
131+
bool
115132
"""
116133
url = self._build_url('tests', base_url=self._api)
117134
return self._boolean(self._post(url), 204, 404)

0 commit comments

Comments
 (0)
0