def parse(cls, api, json): ss = cls(api) for k, v in json.items(): if k == 'created_at': setattr(ss, k, parse_datetime(v)) else: setattr(ss, k, v) return ss
def parse(cls, api, json): dm = cls(api) for k, v in json.items(): if k == 'sender' or k == 'recipient': setattr(dm, k, User.parse(api, v)) elif k == 'created_at': setattr(dm, k, parse_datetime(v)) else: setattr(dm, k, v) return dm
def parse(cls, api, json): comments = cls(api) for k, v in json.items(): if k == 'user': user = User.parse(api, v) setattr(comments, 'author', user) setattr(comments, 'user', user) elif k == 'status': status = Status.parse(api, v) setattr(comments, 'user', status) elif k == 'created_at': setattr(comments, k, parse_datetime(v)) elif k == 'reply_comment': setattr(comments, k, User.parse(api, v)) else: setattr(comments, k, v) return comments
def parse(cls, api, json): user = cls(api) for k, v in json.items(): if k == 'created_at': setattr(user, k, parse_datetime(v)) elif k == 'status': setattr(user, k, Status.parse(api, v)) elif k == 'screen_name': setattr(user, k, v) elif k == 'following': # twitter sets this to null if it is false if v is True: setattr(user, k, True) else: setattr(user, k, False) else: setattr(user, k, v) return user
def parse(cls, api, json): status = cls(api) for k, v in json.items(): if k == 'user': user = User.parse(api, v) setattr(status, 'author', user) setattr(status, 'user', user) # DEPRECIATED elif k == 'screen_name': setattr(status, k, v) elif k == 'created_at': setattr(status, k, parse_datetime(v)) elif k == 'source': if '<' in v: setattr(status, k, parse_html_value(v)) setattr(status, 'source_url', parse_a_href(v)) else: setattr(status, k, v) elif k == 'repost_status': setattr(status, k, Status.parse(api, v)) elif k == 'geo': setattr(status, k, Geo.parse(api, v)) else: setattr(status, k, v) return status