本文整理汇总了Python中models.Status.parse方法的典型用法代码示例。如果您正苦于以下问题:Python Status.parse方法的具体用法?Python Status.parse怎么用?Python Status.parse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Status
的用法示例。
在下文中一共展示了Status.parse方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: on_data
# 需要导入模块: from models import Status [as 别名]
# 或者: from models.Status import parse [as 别名]
def on_data(self, data):
"""Called when raw data is received from connection.
Override this method if you wish to manually handle
the stream data. Return False to stop stream and close connection.
"""
if "in_reply_to_status_id" in data:
status = Status.parse(self.api, json.loads(data))
if self.on_status(status) is False:
return False
elif "delete" in data:
delete = json.loads(data)["delete"]["status"]
if self.on_delete(delete["id"], delete["user_id"]) is False:
return False
elif "limit" in data:
if self.on_limit(json.loads(data)["limit"]["track"]) is False:
return False
示例2: on_data
# 需要导入模块: from models import Status [as 别名]
# 或者: from models.Status import parse [as 别名]
def on_data(self, raw_data):
"""Called when raw data is received from connection.
Override this method if you wish to manually handle
the stream data. Return False to stop stream and close connection.
"""
data = json.loads(raw_data)
if 'in_reply_to_status_id' in data:
status = Status.parse(self.api, data)
if self.on_status(status) is False:
return False
elif 'delete' in data:
delete = data['delete']['status']
if self.on_delete(delete['id'], delete['user_id']) is False:
return False
elif 'limit' in data:
if self.on_limit(data['limit']['track']) is False:
return False
elif 'disconnect' in data:
if self.on_disconnect(data['disconnect']) is False:
return False
else:
logging.error("Unknown message type: " + str(raw_data))