Code Duplication    Length = 22-27 lines in 2 locations

comics.py 2 locations

@@ 1327-1353 (lines=27) @@
1324
1325
class ButterSafe(GenericListableComic):
1326
    """Class to retrieve Butter Safe comics."""
1327
    name = 'butter'
1328
    long_name = 'ButterSafe'
1329
    url = 'http://buttersafe.com'
1330
    get_url_from_archive_element = get_href
1331
    comic_link_re = re.compile('^%s/([0-9]*)/([0-9]*)/([0-9]*)/.*' % url)
1332
1333
    @classmethod
1334
    def get_archive_elements(cls):
1335
        archive_url = urljoin_wrapper(cls.url, 'archive/')
1336
        return reversed(get_soup_at_url(archive_url).find_all('a', href=cls.comic_link_re))
1337
1338
    @classmethod
1339
    def get_comic_info(cls, soup, link):
1340
        """Get information about a particular comics."""
1341
        url = cls.get_url_from_archive_element(link)
1342
        title = link.string
1343
        year, month, day = [int(s) for s in cls.comic_link_re.match(url).groups()]
1344
        img = soup.find('div', id='comic').find('img')
1345
        assert img['alt'] == title
1346
        return {
1347
            'title': title,
1348
            'day': day,
1349
            'month': month,
1350
            'year': year,
1351
            'img': [img['src']],
1352
        }
1353
1354
1355
class CalvinAndHobbes(GenericComic):
1356
    """Class to retrieve Calvin and Hobbes comics."""
@@ 1393-1414 (lines=22) @@
1390
1391
class AbstruseGoose(GenericListableComic):
1392
    """Class to retrieve AbstruseGoose Comics."""
1393
    name = 'abstruse'
1394
    long_name = 'Abstruse Goose'
1395
    url = 'http://abstrusegoose.com'
1396
    get_url_from_archive_element = get_href
1397
    comic_url_re = re.compile('^%s/([0-9]*)$' % url)
1398
    comic_img_re = re.compile('^%s/strips/.*' % url)
1399
1400
    @classmethod
1401
    def get_archive_elements(cls):
1402
        archive_url = urljoin_wrapper(cls.url, 'archive')
1403
        return get_soup_at_url(archive_url).find_all('a', href=cls.comic_url_re)
1404
1405
    @classmethod
1406
    def get_comic_info(cls, soup, archive_elt):
1407
        comic_url = cls.get_url_from_archive_element(archive_elt)
1408
        num = int(cls.comic_url_re.match(comic_url).groups()[0])
1409
        return {
1410
            'num': num,
1411
            'title': archive_elt.string,
1412
            'img': [soup.find('img', src=cls.comic_img_re)['src']]
1413
        }
1414
1415
1416
class PhDComics(GenericNavigableComic):
1417
    """Class to retrieve PHD Comics."""