From 48d87039714129b0798a4efba2938d15190af7d8 Mon Sep 17 00:00:00 2001 From: James French Date: Mon, 2 Aug 2010 13:54:34 +0800 Subject: [PATCH] Loads rules from a source file --- icalparse.py | 15 ++++++++++++++- rules.py => parserrules.py | 0 2 files changed, 14 insertions(+), 1 deletion(-) rename rules.py => parserrules.py (100%) diff --git a/icalparse.py b/icalparse.py index a492dfa..1ed6076 100755 --- a/icalparse.py +++ b/icalparse.py @@ -150,6 +150,18 @@ def getHTTPContent(url='',cache='.httplib2-cache'): return '' + +def generateRules(): + '''Attempts to load a series of rules into a list''' + try: + import parserrules + except ImportError: + return [] + + rules = [getattr(parserrules, rule) for rule in dir(parserrules) if callable(getattr(parserrules, rule))] + return rules + + if __name__ == '__main__': from optparse import OptionParser # If the user passed us a 'stdin' argument, we'll go with that, @@ -174,4 +186,5 @@ if __name__ == '__main__': content = getContent(url, options.stdin) cal = lineJoiner(content) ical = splitFields(cal) - print ical + rules = generateRules() + print rules diff --git a/rules.py b/parserrules.py similarity index 100% rename from rules.py rename to parserrules.py -- 2.20.1