From 1831af82269742a4f8830010e8975da823f6eab2 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sat, 11 Apr 2020 14:14:53 +0100 Subject: [PATCH] Simple match --- utils.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/utils.py b/utils.py index 4043f5878..d10688787 100644 --- a/utils.py +++ b/utils.py @@ -740,17 +740,21 @@ def searchBoxPosts(baseDir: str, nickname: str, domain: str, """ path = baseDir + '/accounts/' + nickname + '@' + domain + '/' + boxName if not os.path.isdir(path): + print('SEARCH: directory does not exist ' + path) return [] - regObj = re.compile(searchRegex) - + searchRegex = searchRegex.strip() + # regObj = re.compile(searchRegex) + res = [] for root, dirs, fnames in os.walk(path): for fname in fnames: filePath = os.path.join(root, fname) - with open(filePath, 'r') as file: - data = file.read() - if not regObj.match(data): - continue + with open(filePath, 'r') as postFile: + data = postFile.read() + # if not regObj.match(data): + if searchRegex not in data: + continue + res.append(filePath) if len(res) >= maxResults: return res