def filter_by_first_message_dt(self, start_dt=datetime.min, end_dt=datetime.max):
"""
Returns a copy of self after filtering self.conversations by
conversations whose first messages lie in a datetime interval.
Args:
start_dt: A datetime object satisfying start_dt <= end_dt.
end_dt: A datetime object satisfying start_dt <= end_dt.
Returns:
A UserConversations object that is equal to self after filtering
self.conversations such that the datetime of the first message
in each conversation is in the closed interval
[start_dt, end_dt].
Raises:
EmptyUserConversationsError: Filtering self.conversations results
in an empty list.
"""
if start_dt > end_dt:
raise ValueError('Must have start_dt <= end_dt')
conversation_filter = lambda x: x.messages[0].timestamp >= start_dt and x.messages[0].timestamp <= end_dt
return self.filter_user_conversations(conversation_filter)
user_conversations.py 文件源码
python
阅读 33
收藏 0
点赞 0
评论 0
评论列表
文章目录