获取答案下的所有评论.

        :return: 答案下的所有评论，返回生成器
        :rtype: Comments.Iterable
484885
def comments(self):
        
        import math
        from .author import Author, ANONYMOUS
        from .comment import Comment

        api_url = Get_Answer_Comment_URL.format(self.aid)
        page = pages = 1
        while page <= pages:
            res = self._session.get(api_url + '?page=' + str(page))
            if page == 1:
                total = int(res.json()['paging']['totalCount'])
                if total == 0:
                    return
                pages = math.ceil(total / 30) 
            page += 1

            comment_items = res.json()['data']
            for comment_item in comment_items:
                comment_id = comment_item['id']
                content = comment_item['content']
                upvote_num = comment_item['likesCount']
                time_string = comment_item['createdTime'][:19]
                time = datetime.strptime(time_string, "%Y-%m-%dT%H:%M:%S")

                if comment_item['author'].get('url') is not None:
                    a_url = comment_item['author']['url']
                    a_name = comment_item['author']['name']
                    photo_url_tmp = comment_item['author']['avatar']['template']
                    photo_url_id = comment_item['author']['avatar']['id']
                    a_photo_url = photo_url_tmp.replace(
                            '{id}', photo_url_id).replace('_{size}', '')
                    author_obj = Author(a_url, a_name, photo_url=a_photo_url,
                                        session=self._session)
                else:
                    author_obj = ANONYMOUS

                yield Comment(comment_id, self, author_obj, upvote_num, content, time)
760641
def marvcli_comment_list(datasets):
    
    app = create_app()
    ids = parse_setids(datasets, dbids=True)
    comments = db.session.query(Comment)\
                         .options(db.joinedload(Comment.dataset))\
                         .filter(Comment.dataset_id.in_(ids))
    for comment in sorted(comments, key=lambda x: (x.dataset._setid, x.id)):
        print(comment.dataset.setid, comment.id,
              datetime.datetime.fromtimestamp(int(comment.time_added / 1000)),
              comment.author, repr(comment.text))
357011
def get_comments_at_indexes(self, indexes):
        """"""
        s = self.style[indexes]
        has_comments = np.where(s & comment_bit_mask > 0)[0]
        comments = []
        for where_index in has_comments:
            raw = self.get_raw_index(indexes[where_index])
            try:
                comment = self.rawdata.extra.comments[raw]
            except KeyError:
                comment = None
            comments.append(comment)
        return has_comments, comments
121425
def fetchall(self, mode=5, after=0, parent='any', order_by='id',
                 limit=100, page=0, asc=1):
        
        fields_comments = ['tid', 'id', 'parent', 'created', 'modified',
                           'mode', 'remote_addr', 'text', 'author',
                           'email', 'website', 'likes', 'dislikes']
        fields_threads = ['uri', 'title']
        sql_comments_fields = ', '.join(['comments.' + f
                                         for f in fields_comments])
        sql_threads_fields = ', '.join(['threads.' + f
                                        for f in fields_threads])
        sql = ['SELECT ' + sql_comments_fields + ', ' + sql_threads_fields + ' '
               'FROM comments INNER JOIN threads '
               'ON comments.tid=threads.id '
               'WHERE comments.mode = ? ']
        sql_args = [mode]

        if parent != 'any':
            if parent is None:
                sql.append('AND comments.parent IS NULL')
            else:
                sql.append('AND comments.parent=?')
                sql_args.append(parent)

        # custom sanitization
        if order_by not in ['id', 'created', 'modified', 'likes', 'dislikes', 'tid']:
            sql.append('ORDER BY ')
            sql.append("comments.created")
            if not asc:
                sql.append(' DESC')
        else:
            sql.append('ORDER BY ')
            sql.append('comments.' + order_by)
            if not asc:
                sql.append(' DESC')
            sql.append(", comments.created")

        if limit:
            sql.append('LIMIT ?,?')
            sql_args.append(page * limit)
            sql_args.append(limit)

        rv = self.db.execute(sql, sql_args).fetchall()
        for item in rv:
            yield dict(zip(fields_comments + fields_threads, item))
578686
def _get_comments(group_tasks):
    
    comments = {}
    for status, human in _COMMENTS:
        num_tasks = _get_number_of_tasks_for(status, group_tasks)
        if num_tasks:
            space = "    " if status in _PENDING_SUB_STATUSES else ""
            comments[status] = '{space}* {num_tasks} {human}:\n'.format(
                space=space,
                num_tasks=num_tasks,
                human=human)
    return comments
1243426
public function AllComments()
    {
        $order = $this->owner->getCommentsOption('order_comments_by');
        $comments = Comment::get()
            ->filter('ParentID', $this->owner->ID)
            ->sort($order);
        $this->owner->extend('updateAllComments', $comments);
        return $comments;
    }
170215
def discussions(self):
        
        return comments.get_model().objects.for_model(
            self).filter(is_public=True, is_removed=False)
843554
def itemComments(self):
        
        url = "%s/comments/" % self.root
        params = {
            "f": "json"
        }
        return self._get(url,
                            params,
                            securityHandler=self._securityHandler,
                            proxy_port=self._proxy_port,
                            proxy_url=self._proxy_url)
442994
def list_(self):
        
        with self.lock:
            self.send('LIST')
            list_ = {}

            while self.readable():
                msg = self._recv(expected_replies=('322', '321', '323'))

                if msg[0] == '322':
                    channel, usercount, modes, topic = msg[2].split(' ', 3)
                    modes = modes.replace(':', '', 1).replace(':', '', 1)
                    modes = modes.replace('[', '').replace( \
                                                    ']', '').replace('+', '')
                    list_[channel] = usercount, modes, topic
                elif msg[0] == '321':
                    pass
                elif msg[0] == '323':
                    break

            return list_
1220057
def comments(self, tag, limit=0):
        """"""

        return [comment for comment in CommentsMatch(tag).get_comments(limit)]
757052
def comments(self):
        
        return self.discussions.filter(Q(flags=None) | Q(
            flags__flag=CommentFlag.MODERATOR_APPROVAL))
1077792
def _extract_comments(self):
        """"""
        self._det_file.seek(0, 0)
        for line in self._det_file.readlines():
            line = line.strip()
            if line.startswith('#'):
                self.add_comment(line[1:])
1010296
def list_user_comments(self, topic_id, user_alias=None):
        
        user_alias = user_alias or self.api.user_alias
        comment_start = 0
        results = []
        while comment_start is not None:
            comments = self.list_comments(topic_id, comment_start)
            results += [item for item in comments['results'] if item['author_alias'] == user_alias]
            comment_start = comments['next_start']
        return results
944256
def comment_count(object):
    
    return Comment.objects.filter(
        object_id=object.pk,
        content_type=ContentType.objects.get_for_model(object)
    ).count()
588462
def comments(self):
        

        endpoint = self.links["replies"]
        if self._comments is None:
            self._comments = Feed(endpoint, pypump=self._pump)
        return self._comments
721216
def getcomments(self):
        
        comment_list = self.bugzilla.get_comments([self.bug_id])
        return comment_list['bugs'][str(self.bug_id)]['comments']
1046207
def show_comment(self, value):
        
        comments = self.get_comments()
        comments = [x for x in comments if x['comment'] == value]
        if len(comments) == 0:
            raise Exception("Unknown comment")
        else:
            return comments[0]