Code Duplication    Length = 19-20 lines in 2 locations

comics.py 2 locations

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