Ejemplo n.º 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
Ejemplo n.º 2
0
 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':
             #fixme value of created_at maybe ''
             if v:
                 setattr(status, k, parse_datetime(v))
             else:
                 print 'created_at is null string'
                 setattr(status, k, None)
         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 == 'retweeted_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
Ejemplo n.º 3
0
 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':
             #fixme value of created_at maybe ''
             if v:
                 setattr(status, k, parse_datetime(v))
             else:
                 print 'created_at is null string'
                 setattr(status, k, None)
         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 == 'retweeted_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
Ejemplo n.º 4
0
 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':
             if (v == ''): # When the retweeted tweet is deleted, v is ''
                 setattr(status, k, None)
             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 == 'retweeted_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
Ejemplo n.º 5
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
Ejemplo n.º 6
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
Ejemplo n.º 7
0
Archivo: models.py Proyecto: code2u/jsb
 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 == '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 == 'retweeted_status':
             setattr(status, k, Status.parse(api, v))
         else:
             setattr(status, k, v)
     return status
Ejemplo n.º 8
0
 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 == '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 == 'retweeted_status':
             setattr(status, k, User.parse(api, v))
         else:
             setattr(status, k, v)
     return status