diff --git a/morss.py b/morss.py
index 9b637fe..688ec8a 100644
--- a/morss.py
+++ b/morss.py
@@ -66,33 +66,48 @@ def countWord(txt):
else:
return 0
-def parseOptions():
- url = ''
- options = []
+class ParseOptions:
+ def __init__(self):
+ self.url = ''
+ self.options = {}
+ roptions = []
- if 'REQUEST_URI' in os.environ:
- url = os.environ['REQUEST_URI'][1:]
+ if 'REQUEST_URI' in os.environ:
+ self.url = os.environ['REQUEST_URI'][1:]
- if 'REDIRECT_URL' not in os.environ:
- url = url[len(os.environ['SCRIPT_NAME']):]
+ if 'REDIRECT_URL' not in os.environ:
+ self.url = self.url[len(os.environ['SCRIPT_NAME']):]
- if url.startswith(':'):
- options = url.split('/')[0].split(':')[1:]
- url = url.split('/', 1)[1]
+ if self.url.startswith(':'):
+ roptions = self.url.split('/')[0].split(':')[1:]
+ self.url = self.url.split('/', 1)[1]
+ else:
+ if len(sys.argv) <= 1:
+ return (None, [])
- if urlparse.urlparse(url).scheme not in PROTOCOL:
- url = 'http://' + url
- else:
- if len(sys.argv) <= 1:
- return (None, [])
+ roptions = sys.argv[1:-1]
+ self.url = sys.argv[-1]
- options = sys.argv[1:-1]
- url = sys.argv[-1]
+ if urlparse.urlparse(self.url).scheme not in PROTOCOL:
+ self.url = 'http://' + self.url
- if urlparse.urlparse(url).scheme not in PROTOCOL:
- url = 'http://' + url
+ for option in roptions:
+ split = option.split('=', 1)
+ if len(split) > 1:
+ if split[0].lower() == 'true':
+ self.options[split[0]] = True
+ if split[0].lower() == 'false':
+ self.options[split[0]] = False
- return (url, options)
+ self.options[split[0]] = split[1]
+ else:
+ self.options[split[0]] = True
+
+ def __getattr__(self, key):
+ if key in self.options:
+ return self.options[key]
+ else:
+ return False
class Cache:
"""Light, error-prone caching system."""
@@ -444,7 +459,7 @@ def Gather(url, cachePath, options):
startTime = time.time()
for i, item in enumerate(rss.items):
item = Fix(item, url)
- if 'progress' in options:
+ if options.progress:
if MAX_ITEM == 0:
print '%s/%s' % (i+1, size)
else:
@@ -462,10 +477,10 @@ def Gather(url, cachePath, options):
Fill(item, cache, url)
if item.desc and item.content:
- if 'clip' in options:
+ if options.clip:
item.content = item.desc + "