Code Duplication    Length = 18-20 lines in 9 locations

comics.py 9 locations

@@ 2403-2422 (lines=20) @@
2400
                return link
2401
        return None
2402
2403
    @classmethod
2404
    def get_comic_info(cls, soup, link):
2405
        """Get information about a particular comics."""
2406
        title = soup.find('meta', attrs={'name': 'description'})["content"]
2407
        description = soup.find('div', itemprop='articleBody').text
2408
        author = soup.find('span', itemprop='author copyrightHolder').string
2409
        imgs = soup.find_all('img', itemprop='image')
2410
        assert all(i['title'] == i['alt'] for i in imgs)
2411
        alt = imgs[0]['alt'] if imgs else ""
2412
        date_str = soup.find('time', itemprop='datePublished')["datetime"]
2413
        day = string_to_date(date_str, "%Y-%m-%d %H:%M:%S")
2414
        return {
2415
            'img': [urljoin_wrapper(cls.url, i['src']) for i in imgs],
2416
            'month': day.month,
2417
            'year': day.year,
2418
            'day': day.day,
2419
            'author': author,
2420
            'title': title,
2421
            'alt': alt,
2422
            'description': description,
2423
        }
2424
2425
@@ 2602-2620 (lines=19) @@
2599
    get_first_comic_link = get_a_comicnavbase_comicnavfirst
2600
    get_navi_link = get_link_rel_next
2601
2602
    @classmethod
2603
    def get_comic_info(cls, soup, link):
2604
        """Get information about a particular comics."""
2605
        title = soup.find('h2', class_='post-title').string
2606
        author = soup.find("span", class_="post-author").find("a").string
2607
        date_str = soup.find("span", class_="post-date").string
2608
        day = string_to_date(date_str, "%B %d, %Y")
2609
        imgs = soup.find("div", id="comic").find_all("img")
2610
        assert all(i['alt'] == i['title'] for i in imgs)
2611
        assert len(imgs) <= 1
2612
        alt = imgs[0]['alt'] if imgs else ""
2613
        return {
2614
            'img': [i['src'] for i in imgs],
2615
            'title': title,
2616
            'alt': alt,
2617
            'author': author,
2618
            'day': day.day,
2619
            'month': day.month,
2620
            'year': day.year
2621
        }
2622
2623
@@ 2572-2590 (lines=19) @@
2569
    get_first_comic_link = get_a_comicnavbase_comicnavfirst
2570
    get_navi_link = get_link_rel_next
2571
2572
    @classmethod
2573
    def get_comic_info(cls, soup, link):
2574
        """Get information about a particular comics."""
2575
        title = soup.find('h2', class_='post-title').string
2576
        author = soup.find("span", class_="post-author").find("a").string
2577
        date_str = soup.find("span", class_="post-date").string
2578
        day = string_to_date(date_str, "%B %d, %Y")
2579
        imgs = soup.find("div", id="comic").find_all("img")
2580
        assert all(i['alt'] == i['title'] for i in imgs)
2581
        assert len(imgs) <= 1
2582
        alt = imgs[0]['alt'] if imgs else ""
2583
        return {
2584
            'img': [i['src'] for i in imgs],
2585
            'title': title,
2586
            'alt': alt,
2587
            'author': author,
2588
            'day': day.day,
2589
            'month': day.month,
2590
            'year': day.year
2591
        }
2592
2593
@@ 2491-2509 (lines=19) @@
2488
    get_first_comic_link = get_a_navi_navifirst
2489
    get_navi_link = get_link_rel_next
2490
2491
    @classmethod
2492
    def get_comic_info(cls, soup, link):
2493
        """Get information about a particular comics."""
2494
        title = soup.find("h1", class_="entry-title").string
2495
        author = soup.find("span", class_="author vcard").find("a").string
2496
        date_str = soup.find("span", class_="entry-date").string
2497
        day = string_to_date(date_str, "%B %d, %Y")
2498
        imgs = soup.find("div", id="comic").find_all("img")
2499
        assert all(i['alt'] == i['title'] for i in imgs)
2500
        assert len(imgs) == 1
2501
        alt = imgs[0]['alt']
2502
        return {
2503
            'img': [i['src'] for i in imgs],
2504
            'title': title,
2505
            'alt': alt,
2506
            'author': author,
2507
            'day': day.day,
2508
            'month': day.month,
2509
            'year': day.year
2510
        }
2511
2512
@@ 2017-2035 (lines=19) @@
2014
    get_first_comic_link = get_a_navi_navifirst
2015
    get_navi_link = get_a_navi_navinext
2016
2017
    @classmethod
2018
    def get_comic_info(cls, soup, link):
2019
        """Get information about a particular comics."""
2020
        title = soup.find('h2', class_='post-title').string
2021
        author = soup.find('span', class_='post-author').contents[1].string
2022
        date_str = soup.find('span', class_='post-date').string
2023
        day = string_to_date(date_str, '%B %d, %Y')
2024
        imgs = soup.find('div', class_='comicpane').find_all('img')
2025
        assert imgs
2026
        alt = imgs[0]['title']
2027
        assert all(i['title'] == i['alt'] == alt for i in imgs)
2028
        return {
2029
            'month': day.month,
2030
            'year': day.year,
2031
            'day': day.day,
2032
            'img': [i['src'] for i in imgs],
2033
            'title': title,
2034
            'alt': alt,
2035
            'author': author,
2036
        }
2037
2038
@@ 2664-2681 (lines=18) @@
2661
    get_first_comic_link = get_a_navi_navifirst
2662
    get_navi_link = get_link_rel_next
2663
2664
    @classmethod
2665
    def get_comic_info(cls, soup, link):
2666
        """Get information about a particular comics."""
2667
        title = soup.find('h2', class_='post-title').string
2668
        author = soup.find("span", class_="post-author").find("a").string
2669
        date_str = soup.find("span", class_="post-date").string
2670
        day = string_to_date(date_str, "%B %d, %Y")
2671
        imgs = soup.find("div", id="comic").find_all("img")
2672
        assert all(i['alt'] == i['title'] for i in imgs)
2673
        alt = imgs[0]['alt'] if imgs else ""
2674
        return {
2675
            'img': [i['src'] for i in imgs],
2676
            'title': title,
2677
            'alt': alt,
2678
            'author': author,
2679
            'day': day.day,
2680
            'month': day.month,
2681
            'year': day.year
2682
        }
2683
2684
@@ 2635-2652 (lines=18) @@
2632
    get_first_comic_link = get_a_navi_navifirst
2633
    get_navi_link = get_a_navi_comicnavnext_navinext
2634
2635
    @classmethod
2636
    def get_comic_info(cls, soup, link):
2637
        """Get information about a particular comics."""
2638
        title = soup.find('h2', class_='post-title').string
2639
        author = soup.find("span", class_="post-author").find("a").string
2640
        date_str = soup.find("span", class_="post-date").string
2641
        day = string_to_date(date_str, "%B %d, %Y")
2642
        imgs = soup.find("div", id="comic").find_all("img")
2643
        assert all(i['alt'] == i['title'] for i in imgs)
2644
        alt = imgs[0]['alt'] if imgs else ""
2645
        return {
2646
            'img': [i['src'] for i in imgs],
2647
            'title': title,
2648
            'alt': alt,
2649
            'author': author,
2650
            'day': day.day,
2651
            'month': day.month,
2652
            'year': day.year
2653
        }
2654
2655
@@ 2434-2451 (lines=18) @@
2431
    get_first_comic_link = get_a_navi_navifirst
2432
    get_navi_link = get_a_rel_next
2433
2434
    @classmethod
2435
    def get_comic_info(cls, soup, link):
2436
        """Get information about a particular comics."""
2437
        title = soup.find('h2', class_='post-title').string
2438
        author = soup.find("span", class_="post-author").find("a").string
2439
        date_str = soup.find("span", class_="post-date").string
2440
        day = string_to_date(date_str, "%B %d, %Y")
2441
        imgs = soup.find("div", id="comic").find_all("img")
2442
        alt = imgs[0]['alt']
2443
        assert all(i['alt'] == i['title'] == alt for i in imgs)
2444
        return {
2445
            'img': [i['src'] for i in imgs],
2446
            'title': title,
2447
            'alt': alt,
2448
            'author': author,
2449
            'day': day.day,
2450
            'month': day.month,
2451
            'year': day.year
2452
        }
2453
2454
@@ 933-950 (lines=18) @@
930
    get_first_comic_link = get_div_navfirst_a
931
    get_navi_link = get_a_rel_next
932
933
    @classmethod
934
    def get_comic_info(cls, soup, link):
935
        """Get information about a particular comics."""
936
        title = soup.find('h2', class_='post-title').string
937
        author = soup.find("span", class_="post-author").find("a").string
938
        date_str = soup.find('span', class_='post-date').string
939
        day = string_to_date(date_str, '%B %d, %Y')
940
        imgs = soup.find('div', class_='comicpane').find_all('img')
941
        assert all(i['alt'] == i['title'] for i in imgs)
942
        title2 = imgs[0]['title']
943
        return {
944
            'day': day.day,
945
            'month': day.month,
946
            'year': day.year,
947
            'img': [i['src'] for i in imgs],
948
            'title': title,
949
            'title2': title2,
950
            'author': author,
951
        }
952
953