Code Duplication    Length = 19-20 lines in 2 locations

comics.py 2 locations

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