diff options
author | Waylan Limberg <waylan@gmail.com> | 2008-07-17 15:03:50 -0400 |
---|---|---|
committer | Waylan Limberg <waylan@gmail.com> | 2008-07-17 15:03:50 -0400 |
commit | bf7cf776daa26d734c10a6039efe64113f066045 (patch) | |
tree | 9afdcffa51034928be8f010d8c6a929460c44231 | |
parent | 2edd84eac6d419f7a20f779fbe120dd76ca195a8 (diff) | |
download | markdown-bf7cf776daa26d734c10a6039efe64113f066045.tar.gz markdown-bf7cf776daa26d734c10a6039efe64113f066045.tar.bz2 markdown-bf7cf776daa26d734c10a6039efe64113f066045.zip |
Import failures in load_extension are again silent (Markdown continues without the extension). Added the overridable extendMarkdown method to the Extension class which makes it easy for load_extension to create and return a dummy extension on import failure. Besides, it should be there anyway to document the API.
-rw-r--r-- | markdown.py | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/markdown.py b/markdown.py index b141757..95c5f4b 100644 --- a/markdown.py +++ b/markdown.py @@ -2106,6 +2106,22 @@ class Extension: """ Set a config setting for `key` with the given `value`. """ self.config[key][0] = value + def extendMarkdown(self, md, md_globals): + """ + Add the various proccesors and patterns to the Markdown Instance. + + This method must be overriden by every extension. + + Ketword arguments: + + * md: The Markdown instance. + + * md_globals: All global variables availabel in the markdown module + namespace. + + """ + pass + def load_extension(ext_name, configs = []): """ @@ -2135,11 +2151,12 @@ def load_extension(ext_name, configs = []): try: module = __import__(extension_module_name) - except: - message(CRITICAL, - "couldn't load extension %s (looking for %s module)" + except ImportError: + message(WARN, + "Couldn't load extension '%s' from \"%s\" - continuing without." % (ext_name, extension_module_name) ) - sys.exit(1) + # Return a dummy (do nothing) Extension as silent failure + return Extension(configs={}) return module.makeExtension(configs.items()) |