From baccd3b22b330be444e97a88752e283ad11a1acd Mon Sep 17 00:00:00 2001 From: pictuga Date: Sat, 22 Aug 2020 00:37:34 +0200 Subject: [PATCH] Move parseOptions to cgi.py As it is no longer used in cli.py --- morss/cgi.py | 26 ++++++++++++++++++++++++-- morss/morss.py | 23 ----------------------- 2 files changed, 24 insertions(+), 25 deletions(-) diff --git a/morss/cgi.py b/morss/cgi.py index 7b4b013..1e84519 100644 --- a/morss/cgi.py +++ b/morss/cgi.py @@ -14,12 +14,34 @@ except ImportError: from . import crawler from . import readabilite from .morss import FeedFetch, FeedGather, FeedFormat -from .morss import Options, parseOptions -from .morss import log, DELAY, DEBUG, MorssException +from .morss import Options, log, DELAY, DEBUG, MorssException from . import cred +def parseOptions(options): + """ Turns ['md=True'] into {'md':True} """ + out = {} + + for option in options: + split = option.split('=', 1) + + if len(split) > 1: + if split[0].lower() == 'true': + out[split[0]] = True + + elif split[0].lower() == 'false': + out[split[0]] = False + + else: + out[split[0]] = split[1] + + else: + out[split[0]] = True + + return out + + def cgi_parse_environ(environ): # get options diff --git a/morss/morss.py b/morss/morss.py index bb5b6b0..0ec54b4 100644 --- a/morss/morss.py +++ b/morss/morss.py @@ -87,29 +87,6 @@ class Options: return key in self.options -def parseOptions(options): - """ Turns ['md=True'] into {'md':True} """ - out = {} - - for option in options: - split = option.split('=', 1) - - if len(split) > 1: - if split[0].lower() == 'true': - out[split[0]] = True - - elif split[0].lower() == 'false': - out[split[0]] = False - - else: - out[split[0]] = split[1] - - else: - out[split[0]] = True - - return out - - def ItemFix(item, options, feedurl='/'): """ Improves feed items (absolute links, resolve feedburner links, etc) """