Code Duplication    Length = 16-17 lines in 2 locations

comics.py 2 locations

@@ 4666-4682 (lines=17) @@
4663
4664
    @classmethod
4665
    def get_comic_info(cls, soup, link):
4666
        """Get information about a particular comics."""
4667
        href = link['href']
4668
        num = int(cls.link_re.match(href).groups()[0])
4669
        title = link.string
4670
        imgs = soup.find_all('img', id='comic')
4671
        assert len(imgs) == 1
4672
        year, month, day = [int(s)
4673
                            for s in cls.img_re.match(imgs[0]['src']).groups()]
4674
        return {
4675
            'title': title,
4676
            'day': day,
4677
            'month': month,
4678
            'year': year,
4679
            'img': [i['src'] for i in imgs],
4680
            'num': num,
4681
        }
4682
4683
    @classmethod
4684
    def get_archive_elements(cls):
4685
        archive_url = 'http://www.horovitzcomics.com/comics/archive/'
@@ 763-778 (lines=16) @@
760
    get_navi_link = get_link_rel_next
761
    get_url_from_link = join_cls_url_to_href
762
763
    @classmethod
764
    def get_comic_info(cls, soup, link):
765
        """Get information about a particular comics."""
766
        short_url_re = re.compile('^%s/\\?p=([0-9]*)' % cls.url)
767
        short_url = cls.get_url_from_link(soup.find('link', rel='shortlink'))
768
        num = int(short_url_re.match(short_url).groups()[0])
769
        imgs = soup.find('div', id='comic').find_all('img')
770
        assert len(imgs) == 1
771
        title = imgs[0]['alt']
772
        title2 = imgs[0]['title']
773
        return {
774
            'short_url': short_url,
775
            'title': title,
776
            'title2': title2,
777
            'img': [urljoin_wrapper(cls.url, i['src']) for i in imgs],
778
            'num': num,
779
        }
780
781