diff options
author | Leonard Richardson <leonardr@segfault.org> | 2012-08-20 14:10:29 -0400 |
---|---|---|
committer | Leonard Richardson <leonardr@segfault.org> | 2012-08-20 14:10:29 -0400 |
commit | 0f1e8f4a18ea9e48bc05abdb0a0eb2a75c46f714 (patch) | |
tree | 9df818fd3afe7c135fc3ffc9204508ca02f6e3e8 /bs4/__init__.py | |
parent | 84088ed20f516366b272e05f7f7ccd55c446c178 (diff) |
Raise a more specific error (FeatureNotFound) when a requested
parser or parser feature is not installed. Raise NotImplementedError
instead of ValueError when the user calls insert_before() or
insert_after() on the BeautifulSoup object itself. Patch by Aaron
Devore. [bug=1038301]
Diffstat (limited to 'bs4/__init__.py')
-rw-r--r-- | bs4/__init__.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/bs4/__init__.py b/bs4/__init__.py index 64f8df9..23afa91 100644 --- a/bs4/__init__.py +++ b/bs4/__init__.py @@ -149,7 +149,7 @@ class BeautifulSoup(Tag): features = self.DEFAULT_BUILDER_FEATURES builder_class = builder_registry.lookup(*features) if builder_class is None: - raise ValueError( + raise FeatureNotFound( "Couldn't find a tree builder with the features you " "requested: %s. Do you need to install a parser library?" % ",".join(features)) @@ -208,10 +208,10 @@ class BeautifulSoup(Tag): return navigable def insert_before(self, successor): - raise ValueError("BeautifulSoup objects don't support insert_before().") + raise NotImplementedError("BeautifulSoup objects don't support insert_before().") def insert_after(self, successor): - raise ValueError("BeautifulSoup objects don't support insert_after().") + raise NotImplementedError("BeautifulSoup objects don't support insert_after().") def popTag(self): tag = self.tagStack.pop() @@ -348,6 +348,10 @@ class StopParsing(Exception): pass +class FeatureNotFound(ValueError): + pass + + #By default, act as an HTML pretty-printer. if __name__ == '__main__': import sys |