Code Duplication    Length = 35-36 lines in 2 locations

comics.py 2 locations

@@ 4241-4276 (lines=36) @@
4238
        return reversed(get_soup_at_url(archive_url).find_all('a', href=cls.link_re))
4239
4240
4241
class HorovitzNew(HorovitzComics):
4242
    """Class to retrieve Horovitz new comics."""
4243
    name = 'horovitznew'
4244
    long_name = 'Horovitz New'
4245
    link_re = re.compile('^/comics/new/([0-9]+)$')
4246
4247
4248
class HorovitzClassic(HorovitzComics):
4249
    """Class to retrieve Horovitz classic comics."""
4250
    name = 'horovitzclassic'
4251
    long_name = 'Horovitz Classic'
4252
    link_re = re.compile('^/comics/classic/([0-9]+)$')
4253
4254
4255
class GenericGoComic(GenericNavigableComic):
4256
    """Generic class to handle the logic common to comics from gocomics.com."""
4257
    _categories = ('GOCOMIC', )
4258
4259
    @classmethod
4260
    def get_first_comic_link(cls):
4261
        """Get link to first comics."""
4262
        return get_soup_at_url(cls.url).find('a', class_='fa btn btn-outline-default btn-circle fa-backward sm ')
4263
4264
    @classmethod
4265
    def get_navi_link(cls, last_soup, next_):
4266
        """Get link to next or previous comic."""
4267
        PREV = 'fa btn btn-outline-default btn-circle fa-caret-left sm '
4268
        NEXT = 'fa btn btn-outline-default btn-circle fa-caret-right sm '
4269
        return last_soup.find('a', class_=NEXT if next_ else PREV)
4270
4271
    @classmethod
4272
    def get_url_from_link(cls, link):
4273
        gocomics = 'http://www.gocomics.com'
4274
        return urljoin_wrapper(gocomics, link['href'])
4275
4276
    @classmethod
4277
    def get_comic_info(cls, soup, link):
4278
        """Get information about a particular comics."""
4279
        date_str = soup.find('meta', property='article:published_time')['content']
@@ 3215-3249 (lines=35) @@
3212
            'day': day.day,
3213
            'month': day.month,
3214
            'year': day.year,
3215
            'title': title,
3216
        }
3217
3218
3219
class ConsoliaComics(GenericNavigableComic):
3220
    """Class to retrieve Consolia comics."""
3221
    name = 'consolia'
3222
    long_name = 'consolia'
3223
    url = 'https://consolia-comic.com'
3224
    get_url_from_link = join_cls_url_to_href
3225
3226
    @classmethod
3227
    def get_first_comic_link(cls):
3228
        """Get link to first comics."""
3229
        return get_soup_at_url(cls.url).find('span', class_='first').find('a')
3230
3231
    @classmethod
3232
    def get_navi_link(cls, last_soup, next_):
3233
        """Get link to next or previous comic."""
3234
        return last_soup.find('span', class_='next' if next_ else 'prev').find('a')
3235
3236
    @classmethod
3237
    def get_comic_info(cls, soup, link):
3238
        """Get information about a particular comics."""
3239
        title = soup.find('meta', property='og:title')['content']
3240
        date_str = soup.find('time')["datetime"]
3241
        day = string_to_date(date_str, "%Y-%m-%d")
3242
        imgs = soup.find('div', id='comic').find_all('img')
3243
        alt = imgs[0]['title']
3244
        # article = soup.find('div', id='blag')
3245
        # text = article.encode_contents()
3246
        return {
3247
            'title': title,
3248
            'alt': alt,
3249
            'img': [i['src'] for i in imgs],
3250
            # 'text': text,
3251
            'day': day.day,
3252
            'month': day.month,