Code Duplication    Length = 22-27 lines in 2 locations

comics.py 2 locations

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