

def _build_story(self, all_rows):
    '\n        Builds and returns a list of stories (dicts) from the passed source.\n        '
    all_stories = []
    for (info, detail) in all_rows:
        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')
        is_self = False
        if (link.find('item?id=') is (- 1)):
            domain = info_cells[2].findAll('span')[1].string[2:(- 1)]
        else:
            link = ('%s/%s' % (BASE_URL, link))
            domain = BASE_URL
            is_self = True
        detail_cell = detail.findAll('td')[1]
        detail_concern = detail_cell.contents
        num_comments = (- 1)
        if (re.match('^(\\d+)\\spoint.*', detail_concern[0].string) is not None):
            points = int(re.match('^(\\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('.*=(\\d+)', comment_tag.get('href')).groups()[0])
            comments_link = ('%s/item?id=%d' % (BASE_URL, story_id))
            comment_count = re.match('(\\d+)\\s.*', comment_tag.string)
            try:
                num_comments = int(comment_count.groups()[0])
            except AttributeError:
                num_comments = 0
        else:
            points = 0
            submitter = ''
            submitter_profile = ''
            published_time = ('%s' % detail_concern[0])
            comment_tag = ''
            try:
                story_id = int(re.match('.*=(\\d+)', link).groups()[0])
            except AttributeError:
                story_id = (- 1)
            comments_link = ''
            comment_count = (- 1)
        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

dataset/ETHPy150Open karan/HackerNewsAPI/hn/hn.py HN._build_story/original