diff options
author | Leonard Richardson <leonard.richardson@canonical.com> | 2011-02-20 15:44:16 -0500 |
---|---|---|
committer | Leonard Richardson <leonard.richardson@canonical.com> | 2011-02-20 15:44:16 -0500 |
commit | 032b5f464198b27d6163696484314ce19e7083e1 (patch) | |
tree | ff2c5dabea6ac2b35eae7bcd6f66cc234641de0a | |
parent | 1eb6214cf6e87f552b7f21d62b56a302b1ae68c4 (diff) |
Greatly simplified the module import code by making it take a module, not a module name.
-rw-r--r-- | beautifulsoup/builder/__init__.py | 21 |
1 files changed, 6 insertions, 15 deletions
diff --git a/beautifulsoup/builder/__init__.py b/beautifulsoup/builder/__init__.py index 3983d66..1ece168 100644 --- a/beautifulsoup/builder/__init__.py +++ b/beautifulsoup/builder/__init__.py @@ -165,19 +165,8 @@ class HTMLTreeBuilder(TreeBuilder): return False -def register_builders_from(module_name, add_to_all, - local_to_this_package=False): - # I'm sure this is not the best way to do this. - - # Import the module beautifulsoup.builder.foo or some.other.builder.foo - if local_to_this_package: - fqn = __package__ + '.' + module_name - else: - fqn = module_name - __import__(fqn) - - # Look up the module by its fully-qualified name. - module = sys.modules[fqn] +def register_builders_from(module, add_to_all) + # I'm fairly sure this is not the best way to do this. # Copy everything mentioned in the builder module's __all__ into # this module. @@ -188,5 +177,7 @@ def register_builders_from(module_name, add_to_all, # Add all names from the builder module's __all__ to these names. add_to_all += module.__all__ -register_builders_from('_lxml', __all__, True) -register_builders_from('_html5lib', __all__, True) +import _lxml +register_builders_from(_lxml, __all__) +import html5lib +register_builders_from(_html5lib, __all__) |