Code Duplication    Length = 22-27 lines in 2 locations

comics.py 2 locations

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