Code Duplication    Length = 16-17 lines in 2 locations

comics.py 2 locations

@@ 4312-4328 (lines=17) @@
4309
    long_name = 'Off The Leash Dog (from Tumblr)'
4310
    url = 'http://rupertfawcettsdoggyblog.tumblr.com'
4311
    _categories = ('FAWCETT', )
4312
4313
4314
class HorovitzComics(GenericListableComic):
4315
    """Generic class to handle the logic common to the different comics from Horovitz."""
4316
    url = 'http://www.horovitzcomics.com'
4317
    _categories = ('HOROVITZ', )
4318
    img_re = re.compile('.*comics/([0-9]*)/([0-9]*)/([0-9]*)/.*$')
4319
    link_re = NotImplemented
4320
    get_url_from_archive_element = join_cls_url_to_href
4321
4322
    @classmethod
4323
    def get_comic_info(cls, soup, link):
4324
        """Get information about a particular comics."""
4325
        href = link['href']
4326
        num = int(cls.link_re.match(href).groups()[0])
4327
        title = link.string
4328
        imgs = soup.find_all('img', id='comic')
4329
        assert len(imgs) == 1
4330
        year, month, day = [int(s)
4331
                            for s in cls.img_re.match(imgs[0]['src']).groups()]
@@ 730-745 (lines=16) @@
727
    get_navi_link = get_link_rel_next
728
    get_url_from_link = join_cls_url_to_href
729
730
    @classmethod
731
    def get_comic_info(cls, soup, link):
732
        """Get information about a particular comics."""
733
        short_url_re = re.compile('^%s/\\?p=([0-9]*)' % cls.url)
734
        short_url = cls.get_url_from_link(soup.find('link', rel='shortlink'))
735
        num = int(short_url_re.match(short_url).groups()[0])
736
        imgs = soup.find('div', id='comic').find_all('img')
737
        assert len(imgs) == 1
738
        title = imgs[0]['alt']
739
        title2 = imgs[0]['title']
740
        return {
741
            'short_url': short_url,
742
            'title': title,
743
            'title2': title2,
744
            'img': [urljoin_wrapper(cls.url, i['src']) for i in imgs],
745
            'num': num,
746
        }
747
748