From ce83bffc6e52bf0831a3f60a35e2fa16cf569a7f Mon Sep 17 00:00:00 2001 From: DUO Labs Date: Tue, 1 Feb 2022 20:28:42 -0500 Subject: [PATCH 1/9] Update minimal mode for new Google formatting --- app/filter.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/filter.py b/app/filter.py index df8f243d9..568cb78c8 100644 --- a/app/filter.py +++ b/app/filter.py @@ -12,6 +12,7 @@ from urllib.parse import parse_qs import os +minimal_mode_sections = ['Top stories','Images','People also ask'] def extract_q(q_str: str, href: str) -> str: """Extracts the 'q' element from a result link. This is typically @@ -169,8 +170,11 @@ def pull_child_divs(result_div: BeautifulSoup): for result in self.main_divs: result_children = pull_child_divs(result) if minimal_mode: - if len(result_children) in (1, 3): - continue + if any(f">{x} Date: Tue, 1 Feb 2022 20:31:53 -0500 Subject: [PATCH 2/9] Try to fix "Tabs and spaces" issue --- app/filter.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/filter.py b/app/filter.py index 568cb78c8..0a1cb863a 100644 --- a/app/filter.py +++ b/app/filter.py @@ -170,11 +170,11 @@ def pull_child_divs(result_div: BeautifulSoup): for result in self.main_divs: result_children = pull_child_divs(result) if minimal_mode: - if any(f">{x}{x} Date: Tue, 1 Feb 2022 20:52:30 -0500 Subject: [PATCH 3/9] Try to fix "Tabs and spaces" issue (2) --- app/filter.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/filter.py b/app/filter.py index 0a1cb863a..cde652513 100644 --- a/app/filter.py +++ b/app/filter.py @@ -169,12 +169,12 @@ def pull_child_divs(result_div: BeautifulSoup): # Loop through results and check for the number of child divs in each for result in self.main_divs: result_children = pull_child_divs(result) - if minimal_mode: - if any(f">{x}{x} Date: Tue, 1 Feb 2022 20:53:57 -0500 Subject: [PATCH 4/9] Fix indentation issue --- app/filter.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/filter.py b/app/filter.py index cde652513..629dd62a0 100644 --- a/app/filter.py +++ b/app/filter.py @@ -169,12 +169,12 @@ def pull_child_divs(result_div: BeautifulSoup): # Loop through results and check for the number of child divs in each for result in self.main_divs: result_children = pull_child_divs(result) - if minimal_mode: - if any(f">{x}{x} Date: Wed, 2 Feb 2022 14:41:44 -0500 Subject: [PATCH 5/9] Fix pep8 issue Co-authored-by: Ben Busby --- app/filter.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/filter.py b/app/filter.py index 629dd62a0..27dd1647b 100644 --- a/app/filter.py +++ b/app/filter.py @@ -12,7 +12,7 @@ from urllib.parse import parse_qs import os -minimal_mode_sections = ['Top stories','Images','People also ask'] +minimal_mode_sections = ['Top stories', 'Images', 'People also ask'] def extract_q(q_str: str, href: str) -> str: """Extracts the 'q' element from a result link. This is typically From 2ca96bba9cac5fc63b84e4a52c8bc973d8b741e0 Mon Sep 17 00:00:00 2001 From: DUO Labs Date: Wed, 2 Feb 2022 14:45:45 -0500 Subject: [PATCH 6/9] Fix some more pep8 issues --- app/filter.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/filter.py b/app/filter.py index 27dd1647b..45b883a72 100644 --- a/app/filter.py +++ b/app/filter.py @@ -170,9 +170,10 @@ def pull_child_divs(result_div: BeautifulSoup): for result in self.main_divs: result_children = pull_child_divs(result) if minimal_mode: - if any(f">{x}{x} Date: Wed, 2 Feb 2022 14:48:42 -0500 Subject: [PATCH 7/9] pep8 (3) --- app/filter.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/filter.py b/app/filter.py index 45b883a72..d62870455 100644 --- a/app/filter.py +++ b/app/filter.py @@ -14,6 +14,7 @@ minimal_mode_sections = ['Top stories', 'Images', 'People also ask'] + def extract_q(q_str: str, href: str) -> str: """Extracts the 'q' element from a result link. This is typically either the link to a result's website, or a string. @@ -171,7 +172,7 @@ def pull_child_divs(result_div: BeautifulSoup): result_children = pull_child_divs(result) if minimal_mode: if any(f">{x} Date: Wed, 2 Feb 2022 14:51:15 -0500 Subject: [PATCH 8/9] Fix pep8 (4) --- app/filter.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/filter.py b/app/filter.py index d62870455..85db70de8 100644 --- a/app/filter.py +++ b/app/filter.py @@ -171,7 +171,7 @@ def pull_child_divs(result_div: BeautifulSoup): for result in self.main_divs: result_children = pull_child_divs(result) if minimal_mode: - if any(f">{x}{x} Date: Wed, 2 Feb 2022 14:52:50 -0500 Subject: [PATCH 9/9] Fix indentation issue --- app/filter.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/filter.py b/app/filter.py index 85db70de8..a5fe9286c 100644 --- a/app/filter.py +++ b/app/filter.py @@ -176,7 +176,7 @@ def pull_child_divs(result_div: BeautifulSoup): result.decompose() continue if len(result_children) < self.RESULT_CHILD_LIMIT: - continue + continue else: if len(result_children) < self.RESULT_CHILD_LIMIT: continue