Пример #1
0
 def parse(cls, api, json):
     status = cls(api)
     for k, v in json.items():
         if k == 'user':
             user_model = getattr(api.parser.model_factory, 'user')
             user = user_model.parse(api, v)
             setattr(status, 'author', user)
             setattr(status, 'user', user)  # DEPRECIATED
         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)
                 setattr(status, 'source_url', None)
         elif k == 'retweeted_status':
             setattr(status, k, Status.parse(api, v))
         elif k == 'place':
             if v is not None:
                 setattr(status, k, Place.parse(api, v))
             else:
                 setattr(status, k, None)
         else:
             setattr(status, k, v)
     return status
Пример #2
0
 def parse(cls, api, json):
     status = cls(api)
     for k, v in json.items():
         if k == 'user':
             user_model = getattr(api.parser.model_factory, 'user')
             user = user_model.parse(api, v)
             setattr(status, 'author', user)
             setattr(status, 'user', user)  # DEPRECIATED
         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)
                 setattr(status, 'source_url', None)
         elif k == 'retweeted_status':
             setattr(status, k, Status.parse(api, v))
         elif k == 'place':
             if v is not None:
                 setattr(status, k, Place.parse(api, v))
             else:
                 setattr(status, k, None)
         else:
             setattr(status, k, v)
     return status
Пример #3
0
 def parse(cls, api, json):
     result = cls()
     for k, v in json.items():
         if k == 'created_at':
             setattr(result, k, parse_search_datetime(v))
         elif k == 'source':
             setattr(result, k, parse_html_value(unescape_html(v)))
         else:
             setattr(result, k, v)
     return result
Пример #4
0
 def parse(cls, api, json):
     result = cls()
     for k, v in json.items():
         if k == 'created_at':
             setattr(result, k, parse_search_datetime(v))
         elif k == 'source':
             setattr(result, k, parse_html_value(unescape_html(v)))
         else:
             setattr(result, k, v)
     return result