From 2c8e57bdea3611d12bd76cafb02109241205f700 Mon Sep 17 00:00:00 2001 From: Tobias Gruetzmacher Date: Sun, 22 May 2016 23:56:59 +0200 Subject: [PATCH] Migrate Creators to single-class module. --- dosagelib/plugins/creators.py | 230 ++++++++++++---------------------- scripts/creators.py | 6 +- 2 files changed, 84 insertions(+), 152 deletions(-) diff --git a/dosagelib/plugins/creators.py b/dosagelib/plugins/creators.py index 6d08727cb..0c230b1c5 100644 --- a/dosagelib/plugins/creators.py +++ b/dosagelib/plugins/creators.py @@ -9,158 +9,90 @@ from ..scraper import _ParserScraper from ..helpers import indirectStarter -class _Creators(_ParserScraper): +class Creators(_ParserScraper): imageSearch = '//a[contains(@class,"fancybox")]/img' prevSearch = '//a[@id="nav_prev"]' latestSearch = '//div[contains(@class,"caption")]/a' starter = indirectStarter - def __init__(self, name): - super(_Creators, self).__init__('Creators/' + name) + def __init__(self, name, path, lang=None): + super(Creators, self).__init__('Creators/' + name) + self.url = 'https://www.creators.com/features/' + path + if lang: + self.lang = lang - @property - def url(self): - return 'https://www.creators.com/features/' + self.path - - -class _CreatorsEs(_Creators): - lang = 'es' - - -# Some comics are not listed on the "all" page (too old?) -class CafeconLeche(_Creators): - path = 'cafe-con-leche' - - -class DonaldDuck(_Creators): - path = 'donald-duck' - - -class Flare(_Creators): - path = 'flare' - - -class FlightDeck(_Creators): - path = 'flight-deck' - - -class GirlsAndSports(_Creators): - path = 'girls-and-sports' - - -class HomeOffice(_Creators): - path = 'stay-at-home-dad' - - -class HopeAndDeath(_Creators): - path = 'hope-and-death' - - -class MickeyMouse(_Creators): - path = 'mickey-mouse' - - -class NaturalSelection(_Creators): - path = 'natural-selection' - - -class OffCenter(_Creators): - path = 'off-center' - - -class Recess(_Creators): - path = 'recess' - - -class Rugrats(_Creators): - path = 'rugrats' - - -class TheQuigmans(_Creators): - path = 'the-quigmans' - - -class WinnieThePooh(_Creators): - path = 'winnie-the-pooh' - - -# do not edit anything below since these entries are generated from -# scripts/update_plugins.sh -# START AUTOUPDATE -# Agnes has a duplicate in gocomics -# AndyCapp has a duplicate in gocomics -class AndyMarlette(_Creators): - path = 'andy-marlette' - - -class Archie(_Creators): - path = 'archie' - - -class ArchieSpanish(_CreatorsEs): - path = 'archie-spanish' - - -# AskShagg has a duplicate in gocomics -# BC has a duplicate in gocomics -# BallardStreet has a duplicate in gocomics -# BobGorrell has a duplicate in gocomics -# ChipBok has a duplicate in gocomics -# ChrisBritt has a duplicate in gocomics -# ChuckleBros has a duplicate in gocomics -# DaddysHome has a duplicate in gocomics -# DiamondLil has a duplicate in gocomics -# DogEatDoug has a duplicate in gocomics -# DogsOfCKennel has a duplicate in gocomics -# FloAndFriends has a duplicate in gocomics -# ForHeavensSake has a duplicate in gocomics -# FreeRange has a duplicate in gocomics -# GaryMarkstein has a duplicate in gocomics -# GaryVarvel has a duplicate in gocomics -# Heathcliff has a duplicate in gocomics -class HeathcliffSpanish(_CreatorsEs): - path = 'heathcliff-spanish' - - -# HerbAndJamaal has a duplicate in gocomics -# JohnDeering has a duplicate in gocomics -# KenCatalino has a duplicate in gocomics -# LibertyMeadows has a duplicate in gocomics -class LongStoryShort(_Creators): - path = 'long-story-short' - - -# MarshallRamsey has a duplicate in gocomics -# MichaelRamirez has a duplicate in gocomics -# MikeLuckovich has a duplicate in gocomics -# Momma has a duplicate in gocomics -class Mossprints(_Creators): - path = 'mossprints' - - -# NestHeads has a duplicate in gocomics -# OneBigHappy has a duplicate in gocomics -# PaulSzep has a duplicate in gocomics -# Rubes has a duplicate in gocomics -# ScaryGary has a duplicate in gocomics -# SpeedBump has a duplicate in gocomics -# SteveBenson has a duplicate in gocomics -# SteveBreen has a duplicate in gocomics -# SteveKelley has a duplicate in gocomics -# StrangeBrew has a duplicate in gocomics -# TheBarn has a duplicate in gocomics -# TheMeaningOfLila has a duplicate in gocomics -# TheOtherCoast has a duplicate in gocomics -class TomStiglich(_Creators): - path = 'tom-stiglich' - - -# WeePals has a duplicate in gocomics -# WizardOfId has a duplicate in gocomics -class WizardOfIdSpanish(_CreatorsEs): - path = 'wizard-of-id-spanish' - - -# WorkingItOut has a duplicate in gocomics -# ZackHill has a duplicate in gocomics -# END AUTOUPDATE + @classmethod + def getmodules(cls): + return ( + # Some comics are not listed on the "all" page (too old?) + cls('CafeconLeche', 'cafe-con-leche'), + cls('DonaldDuck', 'donald-duck'), + cls('Flare', 'flare'), + cls('FlightDeck', 'flight-deck'), + cls('GirlsAndSports', 'girls-and-sports'), + cls('HomeOffice', 'stay-at-home-dad'), + cls('HopeAndDeath', 'hope-and-death'), + cls('MickeyMouse', 'mickey-mouse'), + cls('NaturalSelection', 'natural-selection'), + cls('OffCenter', 'off-center'), + cls('Recess', 'recess'), + cls('Rugrats', 'rugrats'), + cls('TheQuigmans', 'the-quigmans'), + cls('WinnieThePooh', 'winnie-the-pooh'), + # do not edit anything below since these entries are generated from + # scripts/creators.py + # START AUTOUPDATE + # Agnes has a duplicate in GoComics/Agnes + # AndyCapp has a duplicate in GoComics/AndyCapp + cls('AndyMarlette', 'andy-marlette'), + cls('Archie', 'archie'), + cls('ArchieSpanish', 'archie-spanish', 'es'), + # AskShagg has a duplicate in GoComics/AskShagg + # BallardStreet has a duplicate in GoComics/BallardStreet + # BC has a duplicate in GoComics/BC + # BobGorrell has a duplicate in GoComics/BobGorrell + # ChipBok has a duplicate in GoComics/ChipBok + # ChrisBritt has a duplicate in GoComics/ChrisBritt + # ChuckleBros has a duplicate in GoComics/ChuckleBros + # DaddysHome has a duplicate in GoComics/DaddysHome + # DiamondLil has a duplicate in GoComics/DiamondLil + # DogEatDoug has a duplicate in GoComics/DogEatDoug + # DogsOfCKennel has a duplicate in GoComics/DogsOfCKennel + # FloAndFriends has a duplicate in GoComics/FloAndFriends + # ForHeavensSake has a duplicate in GoComics/ForHeavensSake + # FreeRange has a duplicate in GoComics/FreeRange + # GaryMarkstein has a duplicate in GoComics/GaryMarkstein + # GaryVarvel has a duplicate in GoComics/GaryVarvel + # Heathcliff has a duplicate in GoComics/Heathcliff + cls('HeathcliffSpanish', 'heathcliff-spanish', 'es'), + # HerbAndJamaal has a duplicate in GoComics/HerbAndJamaal + # JohnDeering has a duplicate in GoComics/JohnDeering + # KenCatalino has a duplicate in GoComics/KenCatalino + # LibertyMeadows has a duplicate in GoComics/LibertyMeadows + cls('LongStoryShort', 'long-story-short'), + # MarshallRamsey has a duplicate in GoComics/MarshallRamsey + # MichaelRamirez has a duplicate in GoComics/MichaelRamirez + # MikeLuckovich has a duplicate in GoComics/MikeLuckovich + # Momma has a duplicate in GoComics/Momma + cls('Mossprints', 'mossprints'), + # NestHeads has a duplicate in GoComics/NestHeads + # OneBigHappy has a duplicate in GoComics/OneBigHappy + # PaulSzep has a duplicate in GoComics/PaulSzep + # Rubes has a duplicate in GoComics/Rubes + # ScaryGary has a duplicate in GoComics/ScaryGary + # SpeedBump has a duplicate in GoComics/SpeedBump + # SteveBenson has a duplicate in GoComics/SteveBenson + # SteveBreen has a duplicate in GoComics/SteveBreen + # SteveKelley has a duplicate in GoComics/SteveKelley + # StrangeBrew has a duplicate in GoComics/StrangeBrew + # TheBarn has a duplicate in GoComics/TheBarn + # TheMeaningOfLila has a duplicate in GoComics/TheMeaningOfLila + # TheOtherCoast has a duplicate in GoComics/TheOtherCoast + cls('TomStiglich', 'tom-stiglich'), + # WeePals has a duplicate in GoComics/WeePals + # WizardOfId has a duplicate in GoComics/WizardOfId + cls('WizardOfIdSpanish', 'wizard-of-id-spanish', 'es'), + # WorkingItOut has a duplicate in GoComics/WorkingItOut + # ZackHill has a duplicate in GoComics/ZackHill + # END AUTOUPDATE + ) diff --git a/scripts/creators.py b/scripts/creators.py index 5de1a9f54..333dd599d 100755 --- a/scripts/creators.py +++ b/scripts/creators.py @@ -36,9 +36,9 @@ class CreatorsUpdater(ComicListUpdater): self.handle_url('https://www.creators.com/categories/comics/all') self.handle_url('https://www.creators.com/categories/cartoons/all') - def get_entry(self, name, data): - lang = 'Es' if name.lower().endswith('spanish') else '' - return u"class %s(_Creators%s):\n path = %r" % (name, lang, data) + def get_entry(self, name, path): + langopt = ", 'es'" if name.lower().endswith('spanish') else '' + return u"cls('%s', '%s'%s)," % (name, path, langopt) if __name__ == '__main__': CreatorsUpdater(__file__).run()