agent.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:flow-dashboard 作者: onejgordon 项目源码 文件源码
def _habit_status(self):
        habits = Habit.All(self.user)
        today = datetime.today().date()
        habitday_keys = [ndb.Key('HabitDay', HabitDay.ID(h, today), parent=self.user.key) for h in habits]
        habitdays = ndb.get_multi(habitday_keys)
        n_habits_done = 0
        habits_committed_undone = []
        habits_done = []
        for hd in habitdays:
            if hd:
                habit = hd.habit.get()
                if hd.committed and not hd.done:
                    if habit:
                        habits_committed_undone.append(habit.name)
                if hd.done:
                    habits_done.append(habit.name)
                    n_habits_done += 1
        if habits:
            if n_habits_done:
                text = "Good work on doing %d %s (%s)!" % (
                    n_habits_done,
                    tools.pluralize('habit', n_habits_done),
                    tools.english_list(habits_done)
                )
            else:
                text = "No habits done yet."
            if habits_committed_undone:
                text += " Don't forget you've committed to %s." % tools.english_list(habits_committed_undone)
        else:
            text = "You haven't added any habits yet. Try saying 'add habit run'"
        return text
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号