diff --git a/config_template.py b/config_template.py index 97b6828..02788bd 100755 --- a/config_template.py +++ b/config_template.py @@ -1,8 +1,13 @@ -# Copyright: (2013-2014) Michael Till Beck +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + +# Copyright: (2013-2017) Michael Till Beck # License: GPL-2.0+ -#We collect xpath snippets at this place: Snippet collection - please feel free to add your own definitions! +# We collect xpath snippets at this place: +# Snippet collection +# Feel free to contribute! from mwctools import URLReceiver as uri @@ -13,8 +18,6 @@ from mwctools import Content from mwctools import Parser -import os.path - sites = [ diff --git a/mwc.py b/mwc.py index a6e9cfc..0ed566c 100755 --- a/mwc.py +++ b/mwc.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- -# Copyright: (2013-2015) Michael Till Beck +# Copyright: (2013-2017) Michael Till Beck # License: GPL-2.0+ import io @@ -212,9 +212,9 @@ def pollWebsites(): config = importlib.import_module(configMod) if dryrun: - for site in config.sites: - if site['name'] == dryrun: - parseResult = runParsers(site['parsers']) + for thesite in config.sites: + if thesite['name'] == dryrun: + parseResult = runParsers(thesite['parsers']) for p in parseResult: print(p.title) print(p.content) diff --git a/mwcfeedserver.py b/mwcfeedserver.py index 98093b9..0bca4b0 100755 --- a/mwcfeedserver.py +++ b/mwcfeedserver.py @@ -1,35 +1,38 @@ -#!/usr/bin/python3 +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- -# Copyright: (2013-2014) Michael Till Beck +# Copyright: (2013-2017) Michael Till Beck # License: GPL-2.0+ + import http.server import socketserver import importlib import sys import getopt + bind = 'localhost' port = 8000 configMod = 'config' try: - opts, args = getopt.getopt(sys.argv[1:], 'hc:b:p:', ['help', 'config=', 'bind=', 'port=']) + opts, args = getopt.getopt(sys.argv[1:], 'hc:b:p:', ['help', 'config=', 'bind=', 'port=']) except getopt.GetoptError: - print('Usage: FeedServer.py --config=config --port=8000') - sys.exit(1) + print('Usage: FeedServer.py --config=config --port=8000 --bind=localhost') + sys.exit(1) for opt, arg in opts: - if opt == '-h': - print('Usage: FeedServer.py --config=config --bind=localhost --port=8000') - exit() - elif opt in ('-c', '--config'): - configMod = arg - elif opt in ('-b', '--bind'): - bind = arg - elif opt in ('-p', '--port'): - port = int(arg) + if opt == '-h': + print('Usage: FeedServer.py --config=config --bind=localhost --port=8000') + exit() + elif opt in ('-c', '--config'): + configMod = arg + elif opt in ('-b', '--bind'): + bind = arg + elif opt in ('-p', '--port'): + port = int(arg) config = importlib.import_module(configMod) diff --git a/mwctools.py b/mwctools.py index cbb21e1..cefbbf0 100755 --- a/mwctools.py +++ b/mwctools.py @@ -1,4 +1,12 @@ -import urllib.request, urllib.error, urllib.parse +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + +# Copyright: (2013-2017) Michael Till Beck +# License: GPL-2.0+ + + +import urllib.request +import urllib.error import urllib.parse import subprocess @@ -23,13 +31,6 @@ class Receiver(Parser): def __init__(self, uri): self.uri = uri - def run(self): - return super().run(contentList=[]) - - # output: [Content] - def performAction(self): - return self.performAction(contentList=[]) - class Content: def __init__(self, uri, encoding, title, content, contenttype): @@ -129,7 +130,6 @@ def performAction(self, contentList): result.extend(self.parseOneObject(content)) return result - # input: Content, output: [Content] def parseOneObject(self, content): baseuri = content.uri @@ -201,7 +201,6 @@ def __init__(self, contentregex, titleregex=None): self.contentregex = contentregex self.titleregex = titleregex - # input: [Content], output: [Content] def performAction(self, contentList): result = [] @@ -209,7 +208,6 @@ def performAction(self, contentList): result.extend(self.parseOneObject(content)) return result - # input: Content, output: [Content] def parseOneObject(self, content): contents = []