def cmd_ts(self, group_slug=None):
        def latest_message(x):
            return x.get('date_latest_message')

        try:
            all_topics = list(self.convore.get_topics().values())
            groups = list(self.convore.get_groups().values())
        except NetworkError, e:
            error(unicode(e))
            return

        if group_slug:
            groups = [g for g in groups
                        if g.get('slug') == group_slug]
            if not groups:
                error('group "{0}" not found'.format(group_slug))
                return

        groups = sorted(groups, key=latest_message, reverse=True)

        for group in groups:
            output('{name}:'.format(
                name=group.get('slug', '(unknown)')))
            topics = [t for t in all_topics
                        if t.get('group') == group.get('id')]
            topics = sorted(topics, key=latest_message, reverse=True)
            for topic in topics:
                unread = topic.get('unread', 0)
                if not group_slug and unread == 0:
                    continue
                msg = '  {mark} {id:6} {new:2} {name}'.format(
                    mark='*' if topic.get('id') == self.topic else ' ',
                    id=topic.get('id', '?'),
                    new=unread if 0 > unread else '',
                    name=topic.get('name', '(unknown)'))
                output(msg)
dataset/ETHPy150Open vlasovskikh/convoread/convoread/console.py/Console.cmd_ts/swapped operands of `>`