Code Duplication    Length = 19-20 lines in 2 locations

comics.py 2 locations

@@ 2300-2319 (lines=20) @@
2297
    def get_url_from_archive_element(cls, tr):
2298
        """Get url corresponding to an archive element."""
2299
        td_num, td_comic, td_date, _ = tr.find_all('td')
2300
        link = td_comic.find('a')
2301
        return urljoin_wrapper(cls.url, link['href'])
2302
2303
    @classmethod
2304
    def get_comic_info(cls, soup, tr):
2305
        """Get information about a particular comics."""
2306
        td_num, td_comic, td_date, _ = tr.find_all('td')
2307
        num = int(td_num.string)
2308
        link = td_comic.find('a')
2309
        title = link.string
2310
        imgs = soup.find_all('img', id='comic_image')
2311
        date_str = td_date.string
2312
        day = string_to_date(remove_st_nd_rd_th_from_date(date_str), "%B %d, %Y, %I:%M %p")
2313
        assert len(imgs) == 1
2314
        assert all(i.get('alt') == i.get('title') for i in imgs)
2315
        return {
2316
            'num': num,
2317
            'title': title,
2318
            'alt': imgs[0].get('alt', ''),
2319
            'img': [i['src'] for i in imgs],
2320
            'month': day.month,
2321
            'year': day.year,
2322
            'day': day.day,
@@ 1968-1986 (lines=19) @@
1965
        return reversed(get_soup_at_url(archive_url).find_all('td', class_='archive-title'))
1966
1967
    @classmethod
1968
    def get_url_from_archive_element(cls, td):
1969
        return td.find('a')['href']
1970
1971
    @classmethod
1972
    def get_comic_info(cls, soup, td):
1973
        """Get information about a particular comics."""
1974
        url = cls.get_url_from_archive_element(td)
1975
        title = td.find('a').string
1976
        month_and_day = td.previous_sibling.string
1977
        link_re = re.compile('^%s/([0-9]+)/' % cls.url)
1978
        year = link_re.match(url).groups()[0]
1979
        date_str = month_and_day + ' ' + year
1980
        day = string_to_date(date_str, '%b %d %Y')
1981
        imgs = [soup.find('div', id='comic').find('img')]
1982
        assert len(imgs) == 1
1983
        assert all(i['title'] == i['alt'] == title for i in imgs)
1984
        return {
1985
            'month': day.month,
1986
            'year': day.year,
1987
            'day': day.day,
1988
            'img': [urljoin_wrapper(cls.url, i['src']) for i in imgs],
1989
            'title': title,