1
1
# -*- coding: utf-8 -*-
2
+ """GitHub Pages related logic."""
2
3
from __future__ import unicode_literals
3
- from ..models import GitHubCore
4
4
5
+ from .. import models
5
6
6
- class PagesInfo (GitHubCore ):
7
- def _update_attributes (self , info ):
8
- self ._api = self ._get_attribute (info , 'url' )
9
7
10
- #: Status of the pages site, e.g., built
11
- self .status = self ._get_attribute (info , 'status' )
8
+ class PagesInfo (models .GitHubCore ):
9
+ """Representation of the information about a GitHub pages website.
10
+
11
+ .. attribute:: cname
12
+
13
+ The cname in use for the pages site, if one is set.
12
14
13
- #: CName used for the pages site
14
- self .cname = self ._get_attribute (info , 'cname' )
15
+ .. attribute:: custom_404
15
16
16
- #: Boolean indicating whether there is a custom 404 for the pages site
17
- self .custom_404 = self ._get_attribute (info , 'custom_404' )
17
+ A boolean attribute indicating whether the user configured a custom
18
+ 404 page for this site.
19
+
20
+ .. attribute:: status
21
+
22
+ The current status of the pages site, e.g., ``built``.
23
+ """
24
+
25
+ def _update_attributes (self , info ):
26
+ self ._api = info ['url' ]
27
+ self .cname = info ['cname' ]
28
+ self .custom_404 = info ['custom_404' ]
29
+ self .status = info ['status' ]
18
30
19
31
def _repr (self ):
20
32
info = self .cname or ''
@@ -24,33 +36,52 @@ def _repr(self):
24
36
return '<Pages Info [{0}]>' .format (info )
25
37
26
38
27
- class PagesBuild (GitHubCore ):
28
- def _update_attributes (self , build ):
29
- self ._api = self ._get_attribute (build , 'url' )
39
+ class PagesBuild (models .GitHubCore ):
40
+ """Representation of a single build of a GitHub pages website.
30
41
31
- #: Status of the pages build, e.g., building
32
- self .status = self ._get_attribute (build , 'status' )
42
+ .. attribute:: commit
33
43
34
- #: Error dictionary containing the error message
35
- self .error = self ._get_attribute (build , 'error' )
44
+ The SHA of the commit that triggered this build.
36
45
37
- from .. import users
38
- #: :class:`User <github3.users.User>` representing who pushed the
39
- #: commit
40
- self .pusher = self ._class_attribute (build , 'pusher' , users .ShortUser ,
41
- self )
46
+ .. attribute:: created_at
47
+
48
+ A :class:`~datetime.datetime` object representing the date and time
49
+ when this build was created.
42
50
43
- #: SHA of the commit that triggered the build
44
- self .commit = self ._get_attribute (build , 'commit' )
51
+ .. attribute:: duration
45
52
46
- #: Time the build took to finish
47
- self .duration = self ._get_attribute (build , 'duration' )
53
+ The time it spent processing this build.
48
54
49
- #: Datetime the build was created
50
- self .created_at = self ._strptime_attribute (build , 'created_at' )
55
+ .. attribute:: error
51
56
52
- #: Datetime the build was updated
53
- self .updated_at = self ._strptime_attribute (build , 'updated_at' )
57
+ If this build errored, a dictionary containing the error message and
58
+ details about the error.
59
+
60
+ .. attribute:: pusher
61
+
62
+ A :class:`~github3.users.ShortUser` representing the user who pushed
63
+ the commit that triggered this build.
64
+
65
+ .. attribute:: status
66
+
67
+ The current statues of the build, e.g., ``building``.
68
+
69
+ .. attribute:: updated_at
70
+
71
+ A :class:`~datetime.datetime` object representing the date and time
72
+ when this build was last updated.
73
+ """
74
+
75
+ def _update_attributes (self , build ):
76
+ from .. import users
77
+ self ._api = self ._get_attribute (build , 'url' )
78
+ self .commit = build ['commit' ]
79
+ self .created_at = self ._strptime (build ['created_at' ])
80
+ self .duration = build ['duration' ]
81
+ self .error = build ['error' ]
82
+ self .pusher = users .ShortUser (build ['pusher' ], self )
83
+ self .status = build ['status' ]
84
+ self .updated_at = self ._strptime (build ['updated_at' ])
54
85
55
86
def _repr (self ):
56
87
return '<Pages Build [{0}/{1}]>' .format (self .commit , self .status )
0 commit comments