From 3bbb7de34487e43bb1373b44f45b32cd792cf914 Mon Sep 17 00:00:00 2001 From: Leonard Richardson Date: Thu, 16 Aug 2012 13:28:14 -0400 Subject: As per PEP-8, allow searching by CSS class using the 'class_' keyword argument. [bug=1037624] --- bs4/element.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'bs4/element.py') diff --git a/bs4/element.py b/bs4/element.py index 4a4d3ed..2e3be46 100644 --- a/bs4/element.py +++ b/bs4/element.py @@ -1170,6 +1170,12 @@ class SoupStrainer(object): kwargs['class'] = attrs attrs = None + if 'class_' in kwargs: + # Treat class_="foo" as a search for the 'class' + # attribute, overriding any non-dict value for attrs. + kwargs['class'] = kwargs['class_'] + del kwargs['class_'] + if kwargs: if attrs: attrs = attrs.copy() -- cgit v1.2.3