diff --git a/dosagelib/plugins/comicsdotcom.py b/dosagelib/plugins/comicsdotcom.py deleted file mode 100644 index 2b0dabf9e..000000000 --- a/dosagelib/plugins/comicsdotcom.py +++ /dev/null @@ -1,87 +0,0 @@ -# -*- coding: iso-8859-1 -*- -# Copyright (C) 2004-2005 Tristan Seligmann and Jonathan Jacobs -# Copyright (C) 2012 Bastian Kleineidam -from re import compile, sub - -from ..scraper import _BasicScraper -from ..util import tagre - -def comicsDotCom(name, section): - baseUrl = 'http://www.gocomics.com/' - classname = sub("[^0-9a-zA-Z_]", "", name) - - @classmethod - def namer(cls, imageUrl, pageUrl): - prefix, year, month, day = pageUrl.split('/', 3) - return "%s_%s%s%s.gif" % (name, year, month, day) - - return type('GoComicsDotCom_%s' % classname, - (_BasicScraper,), - dict( - latestUrl=baseUrl + name, - name='GoComicsDotCom/' + classname, - stripUrl=baseUrl + name + '/%s', - imageSearch=compile(tagre("img", "src", r'(http://assets\.amuniversal\.com/[0-9a-f]+)')), - prevSearch=compile(tagre("a", "href", r'(/[^"]+/\d+/\d+/\d+)', after="prev")), - help='Index format: yyyy/mm/dd', - namer=namer) - ) - -# http://www.gocomics.com/features -# XXX - -# http://www.gocomics.com/explore/editorial_list -# XXX - -# http://www.gocomics.com/explore/sherpa_list -# XXX - -agnes = comicsDotCom('agnes', 'creators') -andycapp = comicsDotCom('andycapp', 'creators') -barkeaterlake = comicsDotCom('barkeaterlake', 'comics') -bc = comicsDotCom('bc', 'creators') -ben = comicsDotCom('ben', 'comics') -betty = comicsDotCom('betty', 'comics') -bignate = comicsDotCom('bignate', 'comics') -bonanas = comicsDotCom('bonanas', 'wash') -thebornloser = comicsDotCom('the-born-loser', 'comics') -thebuckets = comicsDotCom('thebuckets', 'comics') -candorville = comicsDotCom('candorville', 'wash') -calvinandhobbes = comicsDotCom('calvinandhobbes', 'comics') -chickweed = comicsDotCom('9chickweedlane', 'comics') -committed = comicsDotCom('committed', 'comics') -dilbert = comicsDotCom('dilbert', 'comics') -drabble = comicsDotCom('drabble', 'comics') -floandfriends = comicsDotCom('floandfriends', 'creators') -frazz = comicsDotCom('frazz', 'comics') -geech = comicsDotCom('geech', 'comics') -getfuzzy = comicsDotCom('getfuzzy', 'comics') -graffiti = comicsDotCom('graffiti', 'comics') -grandave = comicsDotCom('grand-avenue', 'comics') -heathcliff = comicsDotCom('heathcliff', 'creators') -herman = comicsDotCom('herman', 'comics') -janesworld = comicsDotCom('janesworld', 'comics') -jumpstart = comicsDotCom('jumpstart', 'comics') -kitandcarlyle = comicsDotCom('kitandcarlyle', 'comics') -luann = comicsDotCom('luann', 'comics') -marmaduke = comicsDotCom('marmaduke', 'comics') -moderatelyconfused = comicsDotCom('moderately-confused', 'comics') -momma = comicsDotCom('momma', 'creators') -monty = comicsDotCom('monty', 'comics') -nancy = comicsDotCom('nancy', 'comics') -offthemark = comicsDotCom('offthemark', 'comics') -onebighappy = comicsDotCom('onebighappy', 'creators') -peanuts = comicsDotCom('peanuts', 'comics') -pearlsbeforeswine = comicsDotCom('pearlsbeforeswine', 'comics') -pibgorn = comicsDotCom('pibgorn', 'comics') -pickles = comicsDotCom('pickles', 'wash') -redandrover = comicsDotCom('redandrover', 'wash') -roseisrose = comicsDotCom('roseisrose', 'comics') -rubes = comicsDotCom('rubes', 'creators') -rudypark = comicsDotCom('rudypark', 'comics') -speedbump = comicsDotCom('speedbump', 'creators') -strangebrew = comicsDotCom('strangebrew', 'creators') -tarzan = comicsDotCom('tarzan', 'comics') -wizardofid = comicsDotCom('wizardofid', 'creators') -workingdaze = comicsDotCom('working-daze', 'comics') -workingitout = comicsDotCom('workingitout', 'creators') diff --git a/dosagelib/scraper.py b/dosagelib/scraper.py index b7eed6ee1..e02bb9963 100644 --- a/dosagelib/scraper.py +++ b/dosagelib/scraper.py @@ -158,3 +158,8 @@ def check_scrapers(): name2 = d[name].get_name() raise ValueError('Duplicate scrapers %s and %s found' % (name1, name2)) d[name] = scraperclass + + +def make_scraper(classname, **attributes): + """Make a new scraper class with given name and attributes.""" + return type(classname, (_BasicScraper,), attributes) diff --git a/dosagelib/util.py b/dosagelib/util.py index 1f5744d75..49d8f5803 100644 --- a/dosagelib/util.py +++ b/dosagelib/util.py @@ -324,3 +324,8 @@ def strtimezone(): else: zone = time.timezone return "%+04d" % (-zone//3600) + + +def asciify(name): + """Remove non-ascii characters from string.""" + return re.sub("[^0-9a-zA-Z_]", "", name)