Code Duplication    Length = 18-20 lines in 9 locations

comics.py 9 locations

@@ 983-1000 (lines=18) @@
980
    get_first_comic_link = get_div_navfirst_a
981
    get_navi_link = get_a_rel_next
982
983
    @classmethod
984
    def get_comic_info(cls, soup, link):
985
        """Get information about a particular comics."""
986
        title = soup.find('h2', class_='post-title').string
987
        author = soup.find("span", class_="post-author").find("a").string
988
        date_str = soup.find('span', class_='post-date').string
989
        day = string_to_date(date_str, '%B %d, %Y')
990
        imgs = soup.find('div', class_='comicpane').find_all('img')
991
        assert all(i['alt'] == i['title'] for i in imgs)
992
        title2 = imgs[0]['title']
993
        return {
994
            'day': day.day,
995
            'month': day.month,
996
            'year': day.year,
997
            'img': [i['src'] for i in imgs],
998
            'title': title,
999
            'title2': title2,
1000
            'author': author,
1001
        }
1002
1003
@@ 2530-2549 (lines=20) @@
2527
                return link
2528
        return None
2529
2530
    @classmethod
2531
    def get_comic_info(cls, soup, link):
2532
        """Get information about a particular comics."""
2533
        title = soup.find('meta', attrs={'name': 'description'})["content"]
2534
        description = soup.find('div', itemprop='articleBody').text
2535
        author = soup.find('span', itemprop='author copyrightHolder').string
2536
        imgs = soup.find_all('img', itemprop='image')
2537
        assert all(i['title'] == i['alt'] for i in imgs)
2538
        alt = imgs[0]['alt'] if imgs else ""
2539
        date_str = soup.find('time', itemprop='datePublished')["datetime"]
2540
        day = string_to_date(date_str, "%Y-%m-%d %H:%M:%S")
2541
        return {
2542
            'img': [urljoin_wrapper(cls.url, i['src']) for i in imgs],
2543
            'month': day.month,
2544
            'year': day.year,
2545
            'day': day.day,
2546
            'author': author,
2547
            'title': title,
2548
            'alt': alt,
2549
            'description': description,
2550
        }
2551
2552
@@ 2729-2747 (lines=19) @@
2726
    get_first_comic_link = get_a_comicnavbase_comicnavfirst
2727
    get_navi_link = get_link_rel_next
2728
2729
    @classmethod
2730
    def get_comic_info(cls, soup, link):
2731
        """Get information about a particular comics."""
2732
        title = soup.find('h2', class_='post-title').string
2733
        author = soup.find("span", class_="post-author").find("a").string
2734
        date_str = soup.find("span", class_="post-date").string
2735
        day = string_to_date(date_str, "%B %d, %Y")
2736
        imgs = soup.find("div", id="comic").find_all("img")
2737
        assert all(i['alt'] == i['title'] for i in imgs)
2738
        assert len(imgs) <= 1, imgs
2739
        alt = imgs[0]['alt'] if imgs else ""
2740
        return {
2741
            'img': [i['src'] for i in imgs],
2742
            'title': title,
2743
            'alt': alt,
2744
            'author': author,
2745
            'day': day.day,
2746
            'month': day.month,
2747
            'year': day.year
2748
        }
2749
2750
@@ 2699-2717 (lines=19) @@
2696
    get_first_comic_link = get_a_comicnavbase_comicnavfirst
2697
    get_navi_link = get_link_rel_next
2698
2699
    @classmethod
2700
    def get_comic_info(cls, soup, link):
2701
        """Get information about a particular comics."""
2702
        title = soup.find('h2', class_='post-title').string
2703
        author = soup.find("span", class_="post-author").find("a").string
2704
        date_str = soup.find("span", class_="post-date").string
2705
        day = string_to_date(date_str, "%B %d, %Y")
2706
        imgs = soup.find("div", id="comic").find_all("img")
2707
        assert all(i['alt'] == i['title'] for i in imgs)
2708
        assert len(imgs) <= 1, imgs
2709
        alt = imgs[0]['alt'] if imgs else ""
2710
        return {
2711
            'img': [i['src'] for i in imgs],
2712
            'title': title,
2713
            'alt': alt,
2714
            'author': author,
2715
            'day': day.day,
2716
            'month': day.month,
2717
            'year': day.year
2718
        }
2719
2720
@@ 2618-2636 (lines=19) @@
2615
    get_first_comic_link = get_a_navi_navifirst
2616
    get_navi_link = get_link_rel_next
2617
2618
    @classmethod
2619
    def get_comic_info(cls, soup, link):
2620
        """Get information about a particular comics."""
2621
        title = soup.find("h1", class_="entry-title").string
2622
        author = soup.find("span", class_="author vcard").find("a").string
2623
        date_str = soup.find("span", class_="entry-date").string
2624
        day = string_to_date(date_str, "%B %d, %Y")
2625
        imgs = soup.find("div", id="comic").find_all("img")
2626
        assert all(i['alt'] == i['title'] for i in imgs)
2627
        assert len(imgs) == 1, imgs
2628
        alt = imgs[0]['alt']
2629
        return {
2630
            'img': [i['src'] for i in imgs],
2631
            'title': title,
2632
            'alt': alt,
2633
            'author': author,
2634
            'day': day.day,
2635
            'month': day.month,
2636
            'year': day.year
2637
        }
2638
2639
@@ 2060-2078 (lines=19) @@
2057
    get_first_comic_link = get_a_navi_navifirst
2058
    get_navi_link = get_a_navi_navinext
2059
2060
    @classmethod
2061
    def get_comic_info(cls, soup, link):
2062
        """Get information about a particular comics."""
2063
        title = soup.find('h2', class_='post-title').string
2064
        author = soup.find('span', class_='post-author').contents[1].string
2065
        date_str = soup.find('span', class_='post-date').string
2066
        day = string_to_date(date_str, '%B %d, %Y')
2067
        imgs = soup.find('div', class_='comicpane').find_all('img')
2068
        assert imgs
2069
        alt = imgs[0]['title']
2070
        assert all(i['title'] == i['alt'] == alt for i in imgs)
2071
        return {
2072
            'month': day.month,
2073
            'year': day.year,
2074
            'day': day.day,
2075
            'img': [i['src'] for i in imgs],
2076
            'title': title,
2077
            'alt': alt,
2078
            'author': author,
2079
        }
2080
2081
@@ 2791-2808 (lines=18) @@
2788
    get_first_comic_link = get_a_navi_navifirst
2789
    get_navi_link = get_link_rel_next
2790
2791
    @classmethod
2792
    def get_comic_info(cls, soup, link):
2793
        """Get information about a particular comics."""
2794
        title = soup.find('h2', class_='post-title').string
2795
        author = soup.find("span", class_="post-author").find("a").string
2796
        date_str = soup.find("span", class_="post-date").string
2797
        day = string_to_date(date_str, "%B %d, %Y")
2798
        imgs = soup.find("div", id="comic").find_all("img")
2799
        assert all(i['alt'] == i['title'] for i in imgs)
2800
        alt = imgs[0]['alt'] if imgs else ""
2801
        return {
2802
            'img': [i['src'] for i in imgs],
2803
            'title': title,
2804
            'alt': alt,
2805
            'author': author,
2806
            'day': day.day,
2807
            'month': day.month,
2808
            'year': day.year
2809
        }
2810
2811
@@ 2762-2779 (lines=18) @@
2759
    get_first_comic_link = get_a_navi_navifirst
2760
    get_navi_link = get_a_navi_comicnavnext_navinext
2761
2762
    @classmethod
2763
    def get_comic_info(cls, soup, link):
2764
        """Get information about a particular comics."""
2765
        title = soup.find('h2', class_='post-title').string
2766
        author = soup.find("span", class_="post-author").find("a").string
2767
        date_str = soup.find("span", class_="post-date").string
2768
        day = string_to_date(date_str, "%B %d, %Y")
2769
        imgs = soup.find("div", id="comic").find_all("img")
2770
        assert all(i['alt'] == i['title'] for i in imgs)
2771
        alt = imgs[0]['alt'] if imgs else ""
2772
        return {
2773
            'img': [i['src'] for i in imgs],
2774
            'title': title,
2775
            'alt': alt,
2776
            'author': author,
2777
            'day': day.day,
2778
            'month': day.month,
2779
            'year': day.year
2780
        }
2781
2782
@@ 2561-2578 (lines=18) @@
2558
    get_first_comic_link = get_a_navi_navifirst
2559
    get_navi_link = get_a_rel_next
2560
2561
    @classmethod
2562
    def get_comic_info(cls, soup, link):
2563
        """Get information about a particular comics."""
2564
        title = soup.find('h2', class_='post-title').string
2565
        author = soup.find("span", class_="post-author").find("a").string
2566
        date_str = soup.find("span", class_="post-date").string
2567
        day = string_to_date(date_str, "%B %d, %Y")
2568
        imgs = soup.find("div", id="comic").find_all("img")
2569
        alt = imgs[0]['alt']
2570
        assert all(i['alt'] == i['title'] == alt for i in imgs)
2571
        return {
2572
            'img': [i['src'] for i in imgs],
2573
            'title': title,
2574
            'alt': alt,
2575
            'author': author,
2576
            'day': day.day,
2577
            'month': day.month,
2578
            'year': day.year
2579
        }
2580
2581