From 7eedde44d45f99340bcf98384dfb11295ffcebdd Mon Sep 17 00:00:00 2001 From: Leonard Richardson Date: Tue, 7 Feb 2023 10:37:50 -0500 Subject: Removed Soup Sieve fallback method, added documentation. --- bs4/css.py | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) (limited to 'bs4/css.py') diff --git a/bs4/css.py b/bs4/css.py index 8b76139..b237051 100644 --- a/bs4/css.py +++ b/bs4/css.py @@ -33,6 +33,8 @@ class CSS(object): :param tag: All CSS selectors will use this as their starting point. + :param api: A plug-in replacement for the soupsieve module, + designed mainly for use in tests. """ if api is None: raise NotImplementedError( @@ -63,9 +65,9 @@ class CSS(object): """Normalize a list of results to a Resultset. A ResultSet is more consistent with the rest of Beautiful - Soup, and ResultSet.__getattr__ has a helpful error message if - you try to treat a list of results as a single result (a - common mistake). + Soup's API, and ResultSet.__getattr__ has a helpful error + message if you try to treat a list of results as a single + result (a common mistake). """ # Import here to avoid circular import from bs4.element import ResultSet @@ -249,19 +251,3 @@ class CSS(object): select, self.tag, self._ns(namespaces), flags, **kwargs ) ) - - def __getattr__(self, __name): - """Catch-all method that has a chance of giving access to future - methods to be added to Soup Sieve without needing a Beautiful Soup - API change. - - Basically, if you call tag.css.somemethod(selector), this code will - turn that into soupsieve.somemethod(selector, tag). - """ - attr = getattr(self.api, __name) - if callable(attr): - return ( - lambda pattern, *args, __tag=self.tag, __attr=attr, **kwargs: - attr(pattern, __tag, *args, **kwargs) - ) - return attr -- cgit v1.2.3