diff options
author | Waylan Limberg <waylan@gmail.com> | 2010-09-20 15:29:03 -0400 |
---|---|---|
committer | Waylan Limberg <waylan@gmail.com> | 2010-09-20 15:29:03 -0400 |
commit | e2a79787f426bef4c2455d235252362586838773 (patch) | |
tree | 86a0daa8424c5527e726cf58045f8ae3bd51e156 /markdown/extensions/__init__.py | |
parent | af98c981e8540809938952ee549baf65bb951116 (diff) | |
parent | 5366b6908de0daa389ac514eb92c8db3e04148db (diff) | |
download | markdown-e2a79787f426bef4c2455d235252362586838773.tar.gz markdown-e2a79787f426bef4c2455d235252362586838773.tar.bz2 markdown-e2a79787f426bef4c2455d235252362586838773.zip |
Merge branch 'master' of git@gitorious.org:python-markdown/mainline
Diffstat (limited to 'markdown/extensions/__init__.py')
-rw-r--r-- | markdown/extensions/__init__.py | 51 |
1 files changed, 0 insertions, 51 deletions
diff --git a/markdown/extensions/__init__.py b/markdown/extensions/__init__.py index 14e0911..1cc4762 100644 --- a/markdown/extensions/__init__.py +++ b/markdown/extensions/__init__.py @@ -48,54 +48,3 @@ class Extension: raise NotImplementedError, 'Extension "%s.%s" must define an "extendMarkdown"' \ 'method.' % (self.__class__.__module__, self.__class__.__name__) - -def load_extension(ext_name, configs = []): - """Load extension by name, then return the module. - - The extension name may contain arguments as part of the string in the - following format: "extname(key1=value1,key2=value2)" - - """ - - # Parse extensions config params (ignore the order) - configs = dict(configs) - pos = ext_name.find("(") # find the first "(" - if pos > 0: - ext_args = ext_name[pos+1:-1] - ext_name = ext_name[:pos] - pairs = [x.split("=") for x in ext_args.split(",")] - configs.update([(x.strip(), y.strip()) for (x, y) in pairs]) - - # Setup the module names - ext_module = 'markdown.extensions' - module_name_new_style = '.'.join([ext_module, ext_name]) - module_name_old_style = '_'.join(['mdx', ext_name]) - - # Try loading the extention first from one place, then another - try: # New style (markdown.extensons.<extension>) - module = __import__(module_name_new_style, {}, {}, [ext_module]) - except ImportError: - try: # Old style (mdx.<extension>) - module = __import__(module_name_old_style) - except ImportError: - message(WARN, "Failed loading extension '%s' from '%s' or '%s'" - % (ext_name, module_name_new_style, module_name_old_style)) - # Return None so we don't try to initiate none-existant extension - return None - - # If the module is loaded successfully, we expect it to define a - # function called makeExtension() - try: - return module.makeExtension(configs.items()) - except AttributeError, e: - message(CRITICAL, "Failed to initiate extension '%s': %s" % (ext_name, e)) - - -def load_extensions(ext_names): - """Loads multiple extensions""" - extensions = [] - for ext_name in ext_names: - extension = load_extension(ext_name) - if extension: - extensions.append(extension) - return extensions |