Code Duplication    Length = 19-20 lines in 2 locations

comics.py 2 locations

@@ 2378-2397 (lines=20) @@
2375
2376
    @classmethod
2377
    def get_comic_info(cls, soup, tr):
2378
        """Get information about a particular comics."""
2379
        td_num, td_comic, td_date, _ = tr.find_all('td')
2380
        num = int(td_num.string)
2381
        link = td_comic.find('a')
2382
        title = link.string
2383
        imgs = soup.find_all('img', id='comic_image')
2384
        date_str = td_date.string
2385
        day = string_to_date(remove_st_nd_rd_th_from_date(date_str), "%B %d, %Y, %I:%M %p")
2386
        assert len(imgs) == 1
2387
        assert all(i.get('alt') == i.get('title') for i in imgs)
2388
        return {
2389
            'num': num,
2390
            'title': title,
2391
            'alt': imgs[0].get('alt', ''),
2392
            'img': [i['src'] for i in imgs],
2393
            'month': day.month,
2394
            'year': day.year,
2395
            'day': day.day,
2396
        }
2397
2398
2399
class LonnieMillsap(GenericNavigableComic):
2400
    """Class to retrieve Lonnie Millsap's comics."""
@@ 1994-2012 (lines=19) @@
1991
        return td.find('a')['href']
1992
1993
    @classmethod
1994
    def get_comic_info(cls, soup, td):
1995
        """Get information about a particular comics."""
1996
        url = cls.get_url_from_archive_element(td)
1997
        title = td.find('a').string
1998
        month_and_day = td.previous_sibling.string
1999
        link_re = re.compile('^%s/([0-9]+)/' % cls.url)
2000
        year = link_re.match(url).groups()[0]
2001
        date_str = month_and_day + ' ' + year
2002
        day = string_to_date(date_str, '%b %d %Y')
2003
        imgs = [soup.find('div', id='comic').find('img')]
2004
        assert len(imgs) == 1
2005
        assert all(i['title'] == i['alt'] == title for i in imgs)
2006
        return {
2007
            'month': day.month,
2008
            'year': day.year,
2009
            'day': day.day,
2010
            'img': [urljoin_wrapper(cls.url, i['src']) for i in imgs],
2011
            'title': title,
2012
        }
2013
2014
2015
class DiscoBleach(GenericDeletedComic):