Пример #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):
     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
Пример #4
0
 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
Пример #5
0
 def parse(cls, api, json):
     lst = List(api)
     for k,v in json.items():
         if k == 'user':
             setattr(lst, k, User.parse(api, v))
         elif k == 'created_at':
             setattr(lst, k, parse_datetime(v))
         else:
             setattr(lst, k, v)
     return lst
Пример #6
0
 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
Пример #7
0
 def parse(cls, api, json):
     lst = List(api)
     for k, v in json.items():
         if k == 'user':
             setattr(lst, k, User.parse(api, v))
         elif k == 'created_at':
             setattr(lst, k, parse_datetime(v))
         else:
             setattr(lst, k, v)
     return lst
Пример #8
0
 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
Пример #9
0
 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 == '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
Пример #10
0
 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 == '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