Small code clean up

master
pictuga 2018-11-11 16:11:00 +01:00
parent 399e867c94
commit 679628c7fa
3 changed files with 5 additions and 2 deletions

View File

@ -1,4 +1,5 @@
#!/usr/bin/env python
from morss import main, cgi_wrapper as application
if __name__ == '__main__':

View File

@ -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)

View File

@ -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