From 679628c7fa16b9f4dbef4dc041cfbd747e969c4e Mon Sep 17 00:00:00 2001 From: pictuga Date: Sun, 11 Nov 2018 16:11:00 +0100 Subject: [PATCH] Small code clean up --- main.py | 1 + morss/feedify.py | 4 ++++ morss/morss.py | 2 -- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index 239841f..f4c1fd1 100644 --- a/main.py +++ b/main.py @@ -1,4 +1,5 @@ #!/usr/bin/env python + from morss import main, cgi_wrapper as application if __name__ == '__main__': diff --git a/morss/feedify.py b/morss/feedify.py index c01aed4..90739f8 100644 --- a/morss/feedify.py +++ b/morss/feedify.py @@ -39,9 +39,11 @@ def get_rule(link): for section in config.sections(): values = dict(config.items(section)) values['path'] = values['path'].split('\n')[1:] + for path in values['path']: if fnmatch(link, path): return values + return False @@ -115,6 +117,7 @@ def pre_worker(url): class Builder(object): def __init__(self, link, data, rule=None): + # data must be a unicode string self.link = link self.data = data @@ -130,6 +133,7 @@ class Builder(object): if self.rule['mode'] == 'xpath': self.doc = lxml.html.fromstring(self.data) + elif self.rule['mode'] == 'json': self.doc = json.loads(self.data) diff --git a/morss/morss.py b/morss/morss.py index 588da17..c84e896 100644 --- a/morss/morss.py +++ b/morss/morss.py @@ -562,8 +562,6 @@ def cgi_app(environ, start_response): if not options.silent: return out - log('done') - def cgi_wrapper(environ, start_response): # simple http server for html and css