@@ -119,31 +119,36 @@ def _update_attributes(self, event):
119
119
event = copy .deepcopy (event )
120
120
121
121
#: :class:`User <github3.users.User>` object representing the actor.
122
- self .actor = self . _class_attribute (event , 'actor' , EventUser , self )
122
+ self .actor = EventUser (event [ 'actor' ] , self )
123
123
#: datetime object representing when the event was created.
124
- self .created_at = self ._strptime_attribute (event , 'created_at' )
124
+ self .created_at = self ._strptime (event [ 'created_at' ] )
125
125
126
126
#: Unique id of the event
127
- self .id = self . _get_attribute ( event , 'id' )
127
+ self .id = event [ 'id' ]
128
128
129
- #: List all possible types of Events
130
- self .org = self ._class_attribute (event , 'org' , EventOrganization , self )
129
+ #: :class:`EventOrganization <github3.events.EventOrganization>`
130
+ # object representing the org.
131
+ # an event only has an org if the event relates to a resource owned
132
+ # by an org.
133
+ self .org = event .get ('org' )
134
+ if self .org :
135
+ self .org = EventOrganization (event ['org' ], self )
131
136
132
137
#: Event type https://developer.github.com/v3/activity/events/types/
133
- self .type = self . _get_attribute ( event , 'type' )
138
+ self .type = event [ 'type' ]
134
139
handler = _payload_handlers .get (self .type , identity )
135
140
136
141
#: Dictionary with the payload. Payload structure is defined by type_.
137
142
# _type: http://developer.github.com/v3/events/types
138
- self .payload = self . _class_attribute (event , 'payload' , handler , self )
143
+ self .payload = handler (event [ 'payload' ] , self )
139
144
140
145
#: Return ``tuple(owner, repository_name)``
141
- self .repo = self . _get_attribute ( event , 'repo' )
146
+ self .repo = event [ 'repo' ]
142
147
if self .repo :
143
148
self .repo = tuple (self .repo ['name' ].split ('/' ))
144
149
145
150
#: Indicates whether the Event is public or not.
146
- self .public = self . _get_attribute ( event , 'public' )
151
+ self .public = event [ 'public' ]
147
152
148
153
def _repr (self ):
149
154
return '<Event [{0}]>' .format (self .type [:- 5 ])
0 commit comments