Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
mtill committed Sep 8, 2017
1 parent 0d5ab99 commit c01e3d2
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 33 deletions.
11 changes: 7 additions & 4 deletions config_template.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
# Copyright: (2013-2014) Michael Till Beck <[email protected]>
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

# Copyright: (2013-2017) Michael Till Beck <[email protected]>
# License: GPL-2.0+

#We collect xpath snippets at this place: <a href="https://github.com/Debianguru/MailWebsiteChanges/wiki/snippets">Snippet collection</a> - please feel free to add your own definitions!

# We collect xpath snippets at this place:
# <a href="https://github.com/Debianguru/MailWebsiteChanges/wiki/snippets">Snippet collection</a>
# Feel free to contribute!


from mwctools import URLReceiver as uri
Expand All @@ -13,8 +18,6 @@
from mwctools import Content
from mwctools import Parser

import os.path


sites = [

Expand Down
8 changes: 4 additions & 4 deletions mwc.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

# Copyright: (2013-2015) Michael Till Beck <[email protected]>
# Copyright: (2013-2017) Michael Till Beck <[email protected]>
# License: GPL-2.0+

import io
Expand Down Expand Up @@ -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)
Expand Down
31 changes: 17 additions & 14 deletions mwcfeedserver.py
Original file line number Diff line number Diff line change
@@ -1,35 +1,38 @@
#!/usr/bin/python3
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

# Copyright: (2013-2014) Michael Till Beck <[email protected]>
# Copyright: (2013-2017) Michael Till Beck <[email protected]>
# 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)

Expand Down
20 changes: 9 additions & 11 deletions mwctools.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
import urllib.request, urllib.error, urllib.parse
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

# Copyright: (2013-2017) Michael Till Beck <[email protected]>
# License: GPL-2.0+


import urllib.request
import urllib.error
import urllib.parse
import subprocess

Expand All @@ -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):
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -201,15 +201,13 @@ def __init__(self, contentregex, titleregex=None):
self.contentregex = contentregex
self.titleregex = titleregex


# input: [Content], output: [Content]
def performAction(self, contentList):
result = []
for content in contentList:
result.extend(self.parseOneObject(content))
return result


# input: Content, output: [Content]
def parseOneObject(self, content):
contents = []
Expand Down

0 comments on commit c01e3d2

Please sign in to comment.