Code Duplication    Length = 16-17 lines in 2 locations

comics.py 2 locations

@@ 5074-5090 (lines=17) @@
5071
    img_re = re.compile('.*comics/([0-9]*)/([0-9]*)/([0-9]*)/.*$')
5072
    link_re = NotImplemented
5073
    get_url_from_archive_element = join_cls_url_to_href
5074
5075
    @classmethod
5076
    def get_comic_info(cls, soup, link):
5077
        """Get information about a particular comics."""
5078
        href = link['href']
5079
        num = int(cls.link_re.match(href).groups()[0])
5080
        title = link.string
5081
        imgs = soup.find_all('img', id='comic')
5082
        assert len(imgs) == 1, imgs
5083
        year, month, day = [int(s)
5084
                            for s in cls.img_re.match(imgs[0]['src']).groups()]
5085
        return {
5086
            'title': title,
5087
            'day': day,
5088
            'month': month,
5089
            'year': year,
5090
            'img': [i['src'] for i in imgs],
5091
            'num': num,
5092
        }
5093
@@ 808-823 (lines=16) @@
805
    get_first_comic_link = get_div_navfirst_a
806
    get_navi_link = get_link_rel_next
807
    get_url_from_link = join_cls_url_to_href
808
809
    @classmethod
810
    def get_comic_info(cls, soup, link):
811
        """Get information about a particular comics."""
812
        short_url_re = re.compile('^%s/\\?p=([0-9]*)' % cls.url)
813
        short_url = cls.get_url_from_link(soup.find('link', rel='shortlink'))
814
        num = int(short_url_re.match(short_url).groups()[0])
815
        imgs = soup.find('div', id='comic').find_all('img')
816
        assert len(imgs) == 1, imgs
817
        title = imgs[0]['alt']
818
        title2 = imgs[0]['title']
819
        return {
820
            'short_url': short_url,
821
            'title': title,
822
            'title2': title2,
823
            'img': [urljoin_wrapper(cls.url, i['src']) for i in imgs],
824
            'num': num,
825
        }
826