From bf7cf776daa26d734c10a6039efe64113f066045 Mon Sep 17 00:00:00 2001 From: Waylan Limberg Date: Thu, 17 Jul 2008 15:03:50 -0400 Subject: 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. --- markdown.py | 25 +++++++++++++++++++++---- 1 file 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()) -- cgit v1.2.3