Code Duplication    Length = 19-20 lines in 2 locations

comics.py 2 locations

@@ 2300-2319 (lines=20) @@
2297
            'day': day.day,
2298
        }
2299
2300
2301
class AnythingComic(GenericListableComic):
2302
    """Class to retrieve Anything Comics."""
2303
    # Also on http://tapastic.com/series/anything
2304
    name = 'anythingcomic'
2305
    long_name = 'Anything Comic'
2306
    url = 'http://www.anythingcomic.com'
2307
2308
    @classmethod
2309
    def get_archive_elements(cls):
2310
        archive_url = urljoin_wrapper(cls.url, 'archive/')
2311
        # The first 2 <tr>'s do not correspond to comics
2312
        return get_soup_at_url(archive_url).find('table', id='chapter_table').find_all('tr')[2:]
2313
2314
    @classmethod
2315
    def get_url_from_archive_element(cls, tr):
2316
        """Get url corresponding to an archive element."""
2317
        _, td_comic, td_date, _ = tr.find_all('td')
2318
        link = td_comic.find('a')
2319
        return urljoin_wrapper(cls.url, link['href'])
2320
2321
    @classmethod
2322
    def get_comic_info(cls, soup, tr):
@@ 1968-1986 (lines=19) @@
1965
    @classmethod
1966
    def get_comic_info(cls, soup, td):
1967
        """Get information about a particular comics."""
1968
        url = cls.get_url_from_archive_element(td)
1969
        title = td.find('a').string
1970
        month_and_day = td.previous_sibling.string
1971
        link_re = re.compile('^%s/([0-9]+)/' % cls.url)
1972
        year = link_re.match(url).groups()[0]
1973
        date_str = month_and_day + ' ' + year
1974
        day = string_to_date(date_str, '%b %d %Y')
1975
        imgs = [soup.find('div', id='comic').find('img')]
1976
        assert len(imgs) == 1
1977
        assert all(i['title'] == i['alt'] == title for i in imgs)
1978
        return {
1979
            'month': day.month,
1980
            'year': day.year,
1981
            'day': day.day,
1982
            'img': [urljoin_wrapper(cls.url, i['src']) for i in imgs],
1983
            'title': title,
1984
        }
1985
1986
1987
class DiscoBleach(GenericEmptyComic):  # Does not work anymore
1988
    """Class to retrieve Disco Bleach Comics."""
1989
    name = 'discobleach'