/usr/share/pyshared/dosage/scraper.py is in dosage 1.6.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | import os
from zope.interface import Interface
from twisted.plugin import getPlugins
from dosage import plugins
DISABLED_FILES = ('/etc/dosage/disabled',
'~/.dosage/disabled')
disabled = []
for filename in DISABLED_FILES:
filename = os.path.expanduser(filename)
if os.path.exists(filename):
disabled.extend([line.rstrip('\n') for line in open(filename)])
class IScraper(Interface):
"""
I implement a screen-scraping mechanism for traversing web comics and
retrieving the content.
"""
class DisabledComicError(ValueError):
pass
def get(comicName):
"""Returns a comic module object."""
scrapers = getPlugins(IScraper, plugins)
for scraper in scrapers:
if scraper.name == comicName:
return scraper
raise ValueError('Comic %r not found.' % (comicName,))
def items():
scrapers = getPlugins(IScraper, plugins)
return sorted(scrapers, key=lambda s: s.name)
|