Code Duplication    Length = 24-27 lines in 2 locations

comics.py 2 locations

@@ 1361-1387 (lines=27) @@
1358
        }
1359
1360
1361
class ButterSafe(GenericListableComic):
1362
    """Class to retrieve Butter Safe comics."""
1363
    name = 'butter'
1364
    long_name = 'ButterSafe'
1365
    url = 'http://buttersafe.com'
1366
    get_url_from_archive_element = get_href
1367
    comic_link_re = re.compile('^%s/([0-9]*)/([0-9]*)/([0-9]*)/.*' % url)
1368
1369
    @classmethod
1370
    def get_archive_elements(cls):
1371
        archive_url = urljoin_wrapper(cls.url, 'archive/')
1372
        return reversed(get_soup_at_url(archive_url).find_all('a', href=cls.comic_link_re))
1373
1374
    @classmethod
1375
    def get_comic_info(cls, soup, link):
1376
        """Get information about a particular comics."""
1377
        url = cls.get_url_from_archive_element(link)
1378
        title = link.string
1379
        year, month, day = [int(s) for s in cls.comic_link_re.match(url).groups()]
1380
        img = soup.find('div', id='comic').find('img')
1381
        assert img['alt'] == title
1382
        return {
1383
            'title': title,
1384
            'day': day,
1385
            'month': month,
1386
            'year': year,
1387
            'img': [img['src']],
1388
        }
1389
1390
@@ 2037-2060 (lines=24) @@
2034
        }
2035
2036
2037
class PoorlyDrawnLines(GenericListableComic):
2038
    """Class to retrieve Poorly Drawn Lines comics."""
2039
    # Also on http://pdlcomics.tumblr.com
2040
    name = 'poorlydrawn'
2041
    long_name = 'Poorly Drawn Lines'
2042
    url = 'http://poorlydrawnlines.com'
2043
    _categories = ('POORLYDRAWN', )
2044
    get_url_from_archive_element = get_href
2045
2046
    @classmethod
2047
    def get_comic_info(cls, soup, link):
2048
        """Get information about a particular comics."""
2049
        imgs = soup.find('div', class_='post').find_all('img')
2050
        assert len(imgs) <= 1
2051
        return {
2052
            'img': [i['src'] for i in imgs],
2053
            'title': imgs[0].get('title', "") if imgs else "",
2054
        }
2055
2056
    @classmethod
2057
    def get_archive_elements(cls):
2058
        archive_url = urljoin_wrapper(cls.url, 'archive')
2059
        url_re = re.compile('^%s/comic/.' % cls.url)
2060
        return reversed(get_soup_at_url(archive_url).find_all('a', href=url_re))
2061
2062
2063
class LoadingComics(GenericNavigableComic):