From f556c69ea05536aee117638a9cb1d9f81eb4c5b7 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sat, 11 Apr 2020 14:30:54 +0100 Subject: [PATCH] Search your posts with multiple keywords --- utils.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/utils.py b/utils.py index fe631b2ee..4cd98a6d7 100644 --- a/utils.py +++ b/utils.py @@ -743,14 +743,23 @@ def searchBoxPosts(baseDir: str, nickname: str, domain: str, return [] searchStr = searchStr.strip() + if '+' in searchStr: + searchWords = searchStr.split('+') + for index in range(len(searchWords)): + searchWords[index] = searchWords[index].strip() + else: + searchWords = [searchStr] + res = [] for root, dirs, fnames in os.walk(path): for fname in fnames: filePath = os.path.join(root, fname) with open(filePath, 'r') as postFile: data = postFile.read() - if searchStr not in data: - continue + + for keyword in searchWords: + if keyword not in data: + continue res.append(filePath) if len(res) >= maxResults: