Show in a formatted way the stories for each item of the list.
183975
def create_list_stories(
    list_id_stories, number_of_stories, shuffle, max_threads
):
    """"""

    list_stories = []
    with ThreadPoolExecutor(max_workers=max_threads) as executor:
        futures = {
            executor.submit(get_story, new)
            for new in list_id_stories[:number_of_stories]
        }

        for future in tqdm(
            as_completed(futures),
            desc='Getting results',
            unit=' news',
        ):
            list_stories.append(future.result())

    if shuffle:
        random.shuffle(list_stories)
    return list_stories
616402
def view_list(self):
        ''''''
        done = set()
        ret = []
        while len(done) != self.count():
            p = self.view_indexes(done)
            if len(p) > 0:
                ret.append(p)
        return ret
1111302
def list(self):
        
        for i in range(len(self.sections)):
            self.sections[i].list(walkTrace=(i+1,))
903757
def item_lister(command, _connection, page_size, page_number, sort_by,
    sort_order, item_class, result_set, **kwargs):
    
    # pylint: disable=R0913
    page = page_number
    while True:
        item_collection = _connection.get_list(command,
                                             page_size=page_size,
                                             page_number=page,
                                             sort_by=sort_by,
                                             sort_order=sort_order,
                                             item_class=item_class,
                                             **kwargs)
        result_set.total_count = item_collection.total_count
        result_set.page_number = page
        for item in item_collection.items:
            yield item
        if item_collection.total_count < 0 or item_collection.page_size == 0:
            break
        if len(item_collection.items) > 0:
            page += 1
        else:
            break
1273287
def format(self, data, *args, **kwargs):
        '''
        
        '''
        sections = OrderedDict()
        hot_list = []
        normal_list = []
        for item in data:
            meta = item.get('meta', [])

            # 如果标题为空，则迭代下一条目
            if not item.get('title'):
                continue

            soup = BeautifulSoup(item.get('content'), "lxml")

            # 清洗文章内容，去除无用内容
            for view_more in soup.select('.view-more'):
                view_more.extract()
            item['content'] = str(soup.div)

            # 处理文章摘要，若为空则根据正文自动生成并填充
            if not item.get('excerpt') and item.get('content'):
                word_limit = self.options.get(
                    'toc_desc_word_limit', 500)
                content_list = soup.select('div.content')
                content_list = [content.get_text() for content in content_list]
                excerpt = ' '.join(content_list)[:word_limit]
                # 此处摘要信息需进行HTML转义，否则会造成toc.ncx中tag处理错误
                item['excerpt'] = html.escape(excerpt)

            # 从item中提取出section分组
            top = meta.pop('spider.zhihu_daily.top', '0')
            item['meta'] = meta
            if str(top) == '1':
                hot_list.append(item)
            else:
                normal_list.append(item)

        if hot_list:
            sections.setdefault('热闻', hot_list)
        if normal_list:
            sections.setdefault('日报', normal_list)
        return sections
1114648
def enumerate(context, data):
    """"""
    items = ensure_list(context.params.get('items'))
    for item in items:
        data['item'] = item
        context.emit(data=data)
1254062
def output_list(self, category):
        """"""
        print('{} users:'.format(category))
        for user in getattr(self.sub, category):
            print('  {}'.format(user))
130928
def get_stories(label_type):
    

    prefixes = get_story_prefixes(label_type)
    texts = list(set([prefix.split(".")[0].split("/")[1] for prefix in prefixes]))
    return texts
958376
protected void fillList() {

        try {
            getList().setContent(getListItems());
            // initialize detail columns
            Iterator<CmsListItemDetails> itDetails = getList().getMetadata().getItemDetailDefinitions().iterator();
            while (itDetails.hasNext()) {
                initializeDetail(itDetails.next().getId());
            }
        } catch (Exception e) {
            throw new CmsRuntimeException(
                Messages.get().container(Messages.ERR_LIST_FILL_1, getList().getName().key(getLocale()), null),
                e);
        }
    }
196298
def format_items(self, data, many):
        
        if many:
            return [self.format_item(item) for item in data]
        else:
            return self.format_item(data)
489063
def show(self, **kwargs):
        """"""
        show_kwargs = copy.deepcopy(self._show_kwargs)
        show_kwargs.update(kwargs)
        return show_menu(self.entries, **show_kwargs)
1033318
def format_list(self, at_char, user, list_name):
        ''''''
        return '<a href="https://twitter.com/%s/lists/%s">%s%s/%s</a>' \
               % (user, list_name, at_char, user, list_name)
439046
def _contents(self):
        
        stories = [
            "ghosts.md",
            "cricket.md",
            "moochi.md",
            "outwit.md",
            "raid.md",
            "species.md",
            "tennis.md",
            "vagabond.md"
        ]
        story = random.choice(stories)
        with open("static/stimuli/{}".format(story), "r") as f:
            return f.read()
850271
def _build_story(self, all_rows):
        
        # list to hold all stories
        all_stories = []

        for (info, detail) in all_rows:

            #-- Get the into about a story --#
            # split in 3 cells
            info_cells = info.findAll('td')

            rank = int(info_cells[0].string[:-1])
            title = '%s' % info_cells[2].find('a').string
            link = info_cells[2].find('a').get('href')

            # by default all stories are linking posts
            is_self = False

            # the link doesn't contains "http" meaning an internal link
            if link.find('item?id=') is -1:
                # slice " (abc.com) "
                domain = info_cells[2].findAll('span')[1].string[2:-1]
            else:
                link = '%s/%s' % (BASE_URL, link)
                domain = BASE_URL
                is_self = True
            #-- Get the into about a story --#

            #-- Get the detail about a story --#
            # split in 2 cells, we need only second
            detail_cell = detail.findAll('td')[1]
            # list of details we need, 5 count
            detail_concern = detail_cell.contents

            num_comments = -1

            if re.match(r'^(\d+)\spoint.*', detail_concern[0].string) is not \
                    None:
                # can be a link or self post
                points = int(re.match(r'^(\d+)\spoint.*', detail_concern[
                    0].string).groups()[0])
                submitter = '%s' % detail_concern[2].string
                submitter_profile = '%s/%s' % (BASE_URL, detail_concern[
                    2].get('href'))
                published_time = ' '.join(detail_concern[3].strip().split()[
                                          :3])
                comment_tag = detail_concern[4]
                story_id = int(re.match(r'.*=(\d+)', comment_tag.get(
                    'href')).groups()[0])
                comments_link = '%s/item?id=%d' % (BASE_URL, story_id)
                comment_count = re.match(r'(\d+)\s.*', comment_tag.string)
                try:
                    # regex matched, cast to int
                    num_comments = int(comment_count.groups()[0])
                except AttributeError:
                    # did not match, assign 0
                    num_comments = 0
            else:
                # this is a job post
                points = 0
                submitter = ''
                submitter_profile = ''
                published_time = '%s' % detail_concern[0]
                comment_tag = ''
                try:
                    story_id = int(re.match(r'.*=(\d+)', link).groups()[0])
                except AttributeError:
                    # job listing that points to external link
                    story_id = -1
                comments_link = ''
                comment_count = -1
            #-- Get the detail about a story --#

            story = Story(rank, story_id, title, link, domain, points,
                          submitter, published_time, submitter_profile,
                          num_comments, comments_link, is_self)

            all_stories.append(story)

        return all_stories
527106
def sort_list(items):
    """"""

    # Track by number of words.
    track = {}

    def by_length(word1, word2):
        return len(word2) - len(word1)

    # Loop through each item.
    for item in items:
        # Count the words.
        cword = utils.word_count(item, all=True)
        if cword not in track:
            track[cword] = []
        track[cword].append(item)

    # Sort them.
    output = []
    for count in sorted(track.keys(), reverse=True):
        sort = sorted(track[count], key=len, reverse=True)
        output.extend(sort)

    return output
828528
def get_items(self) -> Iterator[StoryItem]:
        """"""
        self._fetch_items()
        yield from (StoryItem(self._context, item, self.owner_profile) for item in self._items)
71243
def story_archive(request, slug, template_name='staffmembers/story_archive.html'):
    
    member = get_object_or_404(StaffMember, slug__iexact=slug, is_active=True)

    stories = []
    if hasattr(member, 'story_set'):
        from story.settings import PUBLISHED_STATUS
        stories = member.story_set.filter(publish_date__lte=datetime.now()
            ).filter(status__exact=PUBLISHED_STATUS
            ).order_by('-publish_date')

    return render_to_response(template_name,
                              {'member': member,
                               'stories': stories},
                              context_instance=RequestContext(request))