Code Duplication    Length = 29-31 lines in 2 locations

comics.py 2 locations

@@ 1482-1512 (lines=31) @@
1479
1480
class Octopuns(GenericEmptyComic, GenericNavigableComic):
1481
    """Class to retrieve Octopuns comics."""
1482
    # Also on http://octopuns.tumblr.com
1483
    name = 'octopuns'
1484
    long_name = 'Octopuns'
1485
    url = 'http://www.octopuns.net'
1486
1487
    @classmethod
1488
    def get_first_comic_link(cls):
1489
        """Get link to first comics."""
1490
        return get_soup_at_url(cls.url).find('img', src=re.compile('.*/First.png')).parent
1491
1492
    @classmethod
1493
    def get_navi_link(cls, last_soup, next_):
1494
        """Get link to next or previous comic."""
1495
        link = last_soup.find('img', src=re.compile('.*/Next.png' if next_ else '.*/Back.png')).parent
1496
        return None if link.get('href') is None else link
1497
1498
    @classmethod
1499
    def get_comic_info(cls, soup, link):
1500
        """Get information about a particular comics."""
1501
        title = soup.find('h3', class_='post-title entry-title').string
1502
        date_str = soup.find('h2', class_='date-header').string
1503
        day = string_to_date(date_str, "%A, %B %d, %Y")
1504
        imgs = soup.find_all('link', rel='image_src')
1505
        return {
1506
            'img': [i['href'] for i in imgs],
1507
            'title': title,
1508
            'day': day.day,
1509
            'month': day.month,
1510
            'year': day.year,
1511
        }
1512
1513
1514
class Quarktees(GenericNavigableComic):
1515
    """Class to retrieve the Quarktees comics."""
@@ 2062-2090 (lines=29) @@
2059
2060
class LoadingComics(GenericNavigableComic):
2061
    """Class to retrieve Loading Artist comics."""
2062
    name = 'loadingartist'
2063
    long_name = 'Loading Artist'
2064
    url = 'http://www.loadingartist.com/latest'
2065
2066
    @classmethod
2067
    def get_first_comic_link(cls):
2068
        """Get link to first comics."""
2069
        return get_soup_at_url(cls.url).find('a', title="First")
2070
2071
    @classmethod
2072
    def get_navi_link(cls, last_soup, next_):
2073
        """Get link to next or previous comic."""
2074
        return last_soup.find('a', title='Next' if next_ else 'Previous')
2075
2076
    @classmethod
2077
    def get_comic_info(cls, soup, link):
2078
        """Get information about a particular comics."""
2079
        title = soup.find('h1').string
2080
        date_str = soup.find('span', class_='date').string.strip()
2081
        day = string_to_date(date_str, "%B %d, %Y")
2082
        imgs = soup.find('div', class_='comic').find_all('img', alt='', title='')
2083
        return {
2084
            'title': title,
2085
            'img': [i['src'] for i in imgs],
2086
            'month': day.month,
2087
            'year': day.year,
2088
            'day': day.day,
2089
        }
2090
2091
2092
class ChuckleADuck(GenericNavigableComic):
2093
    """Class to retrieve Chuckle-A-Duck comics."""