1
1
# -*- coding: utf-8 -*-
2
+ """Module containing the logic for labels."""
2
3
from __future__ import unicode_literals
3
4
4
5
from json import dumps
7
8
8
9
9
10
class Label (GitHubCore ):
10
- """The :class:`Label <Label>` object. Succintly represents a label that
11
- exists in a repository.
11
+ """A representation of a label object defined on a repository.
12
12
13
13
See also: http://developer.github.com/v3/issues/labels/
14
+
15
+ This object has the following attributes::
16
+
17
+ .. attribute:: color
18
+
19
+ The hexadecimeal representation of the background color of this label.
20
+
21
+ .. attribute:: name
22
+
23
+ The name (display label) for this label.
14
24
"""
15
- def _update_attributes (self , label ):
16
- self ._api = self ._get_attribute (label , 'url' )
17
- #: Color of the label, e.g., 626262
18
- self .color = self ._get_attribute (label , 'color' )
19
- #: Name of the label, e.g., 'bug'
20
- self .name = self ._get_attribute (label , 'name' )
21
25
26
+ def _update_attributes (self , label ):
27
+ self ._api = label ['url' ]
28
+ self .color = label ['color' ]
29
+ self .name = label ['name' ]
22
30
self ._uniq = self ._api
23
31
24
32
def _repr (self ):
@@ -31,17 +39,25 @@ def __str__(self):
31
39
def delete (self ):
32
40
"""Delete this label.
33
41
34
- :returns: bool
42
+ :returns:
43
+ True if successfully deleted, False otherwise
44
+ :rtype:
45
+ bool
35
46
"""
36
47
return self ._boolean (self ._delete (self ._api ), 204 , 404 )
37
48
38
49
@requires_auth
39
50
def update (self , name , color ):
40
51
"""Update this label.
41
52
42
- :param str name: (required), new name of the label
43
- :param str color: (required), color code, e.g., 626262, no leading '#'
44
- :returns: bool
53
+ :param str name:
54
+ (required), new name of the label
55
+ :param str color:
56
+ (required), color code, e.g., 626262, no leading '#'
57
+ :returns:
58
+ True if successfully updated, False otherwise
59
+ :rtype:
60
+ bool
45
61
"""
46
62
json = None
47
63
0 commit comments