Code Duplication    Length = 24-26 lines in 5 locations

comics.py 5 locations

@@ 2335-2360 (lines=26) @@
2332
        }
2333
2334
2335
class GerbilWithAJetpack(GenericNavigableComic):
2336
    """Class to retrieve GerbilWithAJetpack comics."""
2337
    name = 'gerbil'
2338
    long_name = 'Gerbil With A Jetpack'
2339
    url = 'http://gerbilwithajetpack.com'
2340
    get_first_comic_link = get_a_navi_navifirst
2341
    get_navi_link = get_a_rel_next
2342
2343
    @classmethod
2344
    def get_comic_info(cls, soup, link):
2345
        """Get information about a particular comics."""
2346
        title = soup.find('h2', class_='post-title').string
2347
        author = soup.find("span", class_="post-author").find("a").string
2348
        date_str = soup.find("span", class_="post-date").string
2349
        day = string_to_date(date_str, "%B %d, %Y")
2350
        imgs = soup.find("div", id="comic").find_all("img")
2351
        alt = imgs[0]['alt']
2352
        assert all(i['alt'] == i['title'] == alt for i in imgs)
2353
        return {
2354
            'img': [i['src'] for i in imgs],
2355
            'title': title,
2356
            'alt': alt,
2357
            'author': author,
2358
            'day': day.day,
2359
            'month': day.month,
2360
            'year': day.year
2361
        }
2362
2363
@@ 2679-2703 (lines=25) @@
2676
        return {'href': 'http://www.commitstrip.com/en/2012/02/22/interview/'}
2677
2678
2679
class GenericBoumerie(GenericNavigableComic):
2680
    """Generic class to retrieve Boumeries comics in different languages."""
2681
    get_first_comic_link = get_a_navi_navifirst
2682
    get_navi_link = get_link_rel_next
2683
    date_format = NotImplemented
2684
    lang = NotImplemented
2685
2686
    @classmethod
2687
    def get_comic_info(cls, soup, link):
2688
        """Get information about a particular comics."""
2689
        title = soup.find('h2', class_='post-title').string
2690
        short_url = soup.find('link', rel='shortlink')['href']
2691
        author = soup.find("span", class_="post-author").find("a").string
2692
        date_str = soup.find('span', class_='post-date').string
2693
        day = string_to_date(date_str, cls.date_format, cls.lang)
2694
        imgs = soup.find('div', id='comic').find_all('img')
2695
        assert all(i['alt'] == i['title'] for i in imgs)
2696
        return {
2697
            'short_url': short_url,
2698
            'img': [i['src'] for i in imgs],
2699
            'title': title,
2700
            'author': author,
2701
            'month': day.month,
2702
            'year': day.year,
2703
            'day': day.day,
2704
        }
2705
2706
@@ 2364-2388 (lines=25) @@
2361
        }
2362
2363
2364
class EveryDayBlues(GenericNavigableComic):
2365
    """Class to retrieve EveryDayBlues Comics."""
2366
    name = "blues"
2367
    long_name = "Every Day Blues"
2368
    url = "http://everydayblues.net"
2369
    get_first_comic_link = get_a_navi_navifirst
2370
    get_navi_link = get_link_rel_next
2371
2372
    @classmethod
2373
    def get_comic_info(cls, soup, link):
2374
        """Get information about a particular comics."""
2375
        title = soup.find("h2", class_="post-title").string
2376
        author = soup.find("span", class_="post-author").find("a").string
2377
        date_str = soup.find("span", class_="post-date").string
2378
        day = string_to_date(date_str, "%d. %B %Y", "de_DE.utf8")
2379
        imgs = soup.find("div", id="comic").find_all("img")
2380
        assert all(i['alt'] == i['title'] == title for i in imgs)
2381
        assert len(imgs) <= 1
2382
        return {
2383
            'img': [i['src'] for i in imgs],
2384
            'title': title,
2385
            'author': author,
2386
            'day': day.day,
2387
            'month': day.month,
2388
            'year': day.year
2389
        }
2390
2391
@@ 1704-1728 (lines=25) @@
1701
        }
1702
1703
1704
class MouseBearComedy(GenericNavigableComic):
1705
    """Class to retrieve Mouse Bear Comedy comics."""
1706
    # Also on http://mousebearcomedy.tumblr.com
1707
    name = 'mousebear'
1708
    long_name = 'Mouse Bear Comedy'
1709
    url = 'http://www.mousebearcomedy.com'
1710
    get_first_comic_link = get_a_navi_navifirst
1711
    get_navi_link = get_a_navi_comicnavnext_navinext
1712
1713
    @classmethod
1714
    def get_comic_info(cls, soup, link):
1715
        """Get information about a particular comics."""
1716
        title = soup.find('h2', class_='post-title').string
1717
        author = soup.find("span", class_="post-author").find("a").string
1718
        date_str = soup.find("span", class_="post-date").string
1719
        day = string_to_date(date_str, '%B %d, %Y')
1720
        imgs = soup.find("div", id="comic").find_all("img")
1721
        assert all(i['alt'] == i['title'] == title for i in imgs)
1722
        return {
1723
            'day': day.day,
1724
            'month': day.month,
1725
            'year': day.year,
1726
            'img': [i['src'] for i in imgs],
1727
            'title': title,
1728
            'author': author,
1729
        }
1730
1731
@@ 1113-1136 (lines=24) @@
1110
    url = 'http://english.bouletcorp.com'
1111
1112
1113
class AmazingSuperPowers(GenericNavigableComic):
1114
    """Class to retrieve Amazing Super Powers comics."""
1115
    name = 'asp'
1116
    long_name = 'Amazing Super Powers'
1117
    url = 'http://www.amazingsuperpowers.com'
1118
    get_first_comic_link = get_a_navi_navifirst
1119
    get_navi_link = get_a_navi_navinext
1120
1121
    @classmethod
1122
    def get_comic_info(cls, soup, link):
1123
        """Get information about a particular comics."""
1124
        author = soup.find("span", class_="post-author").find("a").string
1125
        date_str = soup.find('span', class_='post-date').string
1126
        day = string_to_date(date_str, "%B %d, %Y")
1127
        imgs = soup.find('div', id='comic').find_all('img')
1128
        title = ' '.join(i['title'] for i in imgs)
1129
        assert all(i['alt'] == i['title'] for i in imgs)
1130
        return {
1131
            'title': title,
1132
            'author': author,
1133
            'img': [img['src'] for img in imgs],
1134
            'day': day.day,
1135
            'month': day.month,
1136
            'year': day.year
1137
        }
1138
1139