8000 Update events classes for attribute fetching · pythonthings/github3.py@f64a47e · GitHub
[go: up one dir, main page]

Skip to content

Commit f64a47e

Browse files
committed
Update events classes for attribute fetching
Removes the use of _get_attribute and its ilk. Related-to: sigmavirus24#773
1 parent 17d0fb9 commit f64a47e

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

github3/.DS_Store

6 KB
Binary file not shown.

github3/events.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -119,31 +119,36 @@ def _update_attributes(self, event):
119119
event = copy.deepcopy(event)
120120

121121
#: :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)
123123
#: 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'])
125125

126126
#: Unique id of the event
127-
self.id = self._get_attribute(event, 'id')
127+
self.id = event['id']
128128

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)
131136

132137
#: Event type https://developer.github.com/v3/activity/events/types/
133-
self.type = self._get_attribute(event, 'type')
138+
self.type = event['type']
134139
handler = _payload_handlers.get(self.type, identity)
135140

136141
#: Dictionary with the payload. Payload structure is defined by type_.
137142
# _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)
139144

140145
#: Return ``tuple(owner, repository_name)``
141-
self.repo = self._get_attribute(event, 'repo')
146+
self.repo = event['repo']
142147
if self.repo:
143148
self.repo = tuple(self.repo['name'].split('/'))
144149

145150
#: Indicates whether the Event is public or not.
146-
self.public = self._get_attribute(event, 'public')
151+
self.public = event['public']
147152

148153
def _repr(self):
149154
return '<Event [{0}]>'.format(self.type[:-5])

0 commit comments

Comments
 (0)
0