Code Duplication    Length = 19-20 lines in 2 locations

comics.py 2 locations

@@ 2223-2242 (lines=20) @@
2220
    name = 'anythingcomic'
2221
    long_name = 'Anything Comic'
2222
    url = 'http://www.anythingcomic.com'
2223
2224
    @classmethod
2225
    def get_archive_elements(cls):
2226
        archive_url = urljoin_wrapper(cls.url, 'archive/')
2227
        # The first 2 <tr>'s do not correspond to comics
2228
        return get_soup_at_url(archive_url).find('table', id='chapter_table').find_all('tr')[2:]
2229
2230
    @classmethod
2231
    def get_url_from_archive_element(cls, tr):
2232
        """Get url corresponding to an archive element."""
2233
        td_num, td_comic, td_date, _ = tr.find_all('td')
2234
        link = td_comic.find('a')
2235
        return urljoin_wrapper(cls.url, link['href'])
2236
2237
    @classmethod
2238
    def get_comic_info(cls, soup, tr):
2239
        """Get information about a particular comics."""
2240
        td_num, td_comic, td_date, _ = tr.find_all('td')
2241
        num = int(td_num.string)
2242
        link = td_comic.find('a')
2243
        title = link.string
2244
        imgs = soup.find_all('img', id='comic_image')
2245
        date_str = td_date.string
@@ 1914-1932 (lines=19) @@
1911
1912
class InvisibleBread(GenericListableComic):
1913
    """Class to retrieve Invisible Bread comics."""
1914
    # Also on http://www.gocomics.com/invisible-bread
1915
    name = 'invisiblebread'
1916
    long_name = 'Invisible Bread'
1917
    url = 'http://invisiblebread.com'
1918
1919
    @classmethod
1920
    def get_archive_elements(cls):
1921
        archive_url = urljoin_wrapper(cls.url, 'archives/')
1922
        return reversed(get_soup_at_url(archive_url).find_all('td', class_='archive-title'))
1923
1924
    @classmethod
1925
    def get_url_from_archive_element(cls, td):
1926
        return td.find('a')['href']
1927
1928
    @classmethod
1929
    def get_comic_info(cls, soup, td):
1930
        """Get information about a particular comics."""
1931
        url = cls.get_url_from_archive_element(td)
1932
        title = td.find('a').string
1933
        month_and_day = td.previous_sibling.string
1934
        link_re = re.compile('^%s/([0-9]+)/' % cls.url)
1935
        year = link_re.match(url).groups()[0]