From d9808e176a53da6ae95afb24b86f8291b0afb225 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoffer=20Str=C3=B6mberg?= Date: Sat, 10 Feb 2024 21:49:14 +0100 Subject: [PATCH] improved search function --- src/ifk_scb_compilations/search_scb.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/ifk_scb_compilations/search_scb.py b/src/ifk_scb_compilations/search_scb.py index 2b24a68..4623cd9 100644 --- a/src/ifk_scb_compilations/search_scb.py +++ b/src/ifk_scb_compilations/search_scb.py @@ -65,12 +65,11 @@ def recursive_search(nodes: list) -> None: return results - def search_substring(self, substring: str): + def search_substring(self, *arg: str): """Search for substring in scb db. Args: - substring: String to search for - entry_ids: a list of list with entry ids + arg: Strings to search for Returns: list: elements are tuple with search path and title containing substring @@ -78,7 +77,7 @@ def search_substring(self, substring: str): with open(self.search_tree_file_path, "rt") as f: print(f.readline()) for line in f: - if substring in line: + if all(s.lower() in line.lower() for s in arg): print(line) pass @@ -87,4 +86,4 @@ def search_substring(self, substring: str): if __name__ == "__main__": sSearch = ScbSearch() # sSearch.update_search_tree() - sSearch.search_substring("region") + sSearch.search_substring("region", "luft")