Code Duplication    Length = 16-17 lines in 2 locations

comics.py 2 locations

@@ 4940-4956 (lines=17) @@
4937
class HorovitzComics(GenericDeletedComic, GenericListableComic):
4938
    """Generic class to handle the logic common to the different comics from Horovitz."""
4939
    # Also on https://horovitzcomics.tumblr.com
4940
    url = 'http://www.horovitzcomics.com'
4941
    _categories = ('HOROVITZ', )
4942
    img_re = re.compile('.*comics/([0-9]*)/([0-9]*)/([0-9]*)/.*$')
4943
    link_re = NotImplemented
4944
    get_url_from_archive_element = join_cls_url_to_href
4945
4946
    @classmethod
4947
    def get_comic_info(cls, soup, link):
4948
        """Get information about a particular comics."""
4949
        href = link['href']
4950
        num = int(cls.link_re.match(href).groups()[0])
4951
        title = link.string
4952
        imgs = soup.find_all('img', id='comic')
4953
        assert len(imgs) == 1, imgs
4954
        year, month, day = [int(s)
4955
                            for s in cls.img_re.match(imgs[0]['src']).groups()]
4956
        return {
4957
            'title': title,
4958
            'day': day,
4959
            'month': month,
@@ 782-797 (lines=16) @@
779
    get_navi_link = get_link_rel_next
780
    get_url_from_link = join_cls_url_to_href
781
782
    @classmethod
783
    def get_comic_info(cls, soup, link):
784
        """Get information about a particular comics."""
785
        short_url_re = re.compile('^%s/\\?p=([0-9]*)' % cls.url)
786
        short_url = cls.get_url_from_link(soup.find('link', rel='shortlink'))
787
        num = int(short_url_re.match(short_url).groups()[0])
788
        imgs = soup.find('div', id='comic').find_all('img')
789
        assert len(imgs) == 1, imgs
790
        title = imgs[0]['alt']
791
        title2 = imgs[0]['title']
792
        return {
793
            'short_url': short_url,
794
            'title': title,
795
            'title2': title2,
796
            'img': [urljoin_wrapper(cls.url, i['src']) for i in imgs],
797
            'num': num,
798
        }
799
800