Code Duplication    Length = 19-20 lines in 2 locations

comics.py 2 locations

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