Code Duplication    Length = 19-20 lines in 2 locations

comics.py 2 locations

@@ 2351-2370 (lines=20) @@
2348
        link = td_comic.find('a')
2349
        return urljoin_wrapper(cls.url, link['href'])
2350
2351
    @classmethod
2352
    def get_comic_info(cls, soup, tr):
2353
        """Get information about a particular comics."""
2354
        td_num, td_comic, td_date, _ = tr.find_all('td')
2355
        num = int(td_num.string)
2356
        link = td_comic.find('a')
2357
        title = link.string
2358
        imgs = soup.find_all('img', id='comic_image')
2359
        date_str = td_date.string
2360
        day = string_to_date(remove_st_nd_rd_th_from_date(date_str), "%B %d, %Y, %I:%M %p")
2361
        assert len(imgs) == 1
2362
        assert all(i.get('alt') == i.get('title') for i in imgs)
2363
        return {
2364
            'num': num,
2365
            'title': title,
2366
            'alt': imgs[0].get('alt', ''),
2367
            'img': [i['src'] for i in imgs],
2368
            'month': day.month,
2369
            'year': day.year,
2370
            'day': day.day,
2371
        }
2372
2373
@@ 1967-1985 (lines=19) @@
1964
    def get_url_from_archive_element(cls, td):
1965
        return td.find('a')['href']
1966
1967
    @classmethod
1968
    def get_comic_info(cls, soup, td):
1969
        """Get information about a particular comics."""
1970
        url = cls.get_url_from_archive_element(td)
1971
        title = td.find('a').string
1972
        month_and_day = td.previous_sibling.string
1973
        link_re = re.compile('^%s/([0-9]+)/' % cls.url)
1974
        year = link_re.match(url).groups()[0]
1975
        date_str = month_and_day + ' ' + year
1976
        day = string_to_date(date_str, '%b %d %Y')
1977
        imgs = [soup.find('div', id='comic').find('img')]
1978
        assert len(imgs) == 1
1979
        assert all(i['title'] == i['alt'] == title for i in imgs)
1980
        return {
1981
            'month': day.month,
1982
            'year': day.year,
1983
            'day': day.day,
1984
            'img': [urljoin_wrapper(cls.url, i['src']) for i in imgs],
1985
            'title': title,
1986
        }
1987
1988