forked from indymedia/epicyon
Simple match
parent
82c859852f
commit
1831af8226
16
utils.py
16
utils.py
|
@ -740,17 +740,21 @@ def searchBoxPosts(baseDir: str, nickname: str, domain: str,
|
||||||
"""
|
"""
|
||||||
path = baseDir + '/accounts/' + nickname + '@' + domain + '/' + boxName
|
path = baseDir + '/accounts/' + nickname + '@' + domain + '/' + boxName
|
||||||
if not os.path.isdir(path):
|
if not os.path.isdir(path):
|
||||||
|
print('SEARCH: directory does not exist ' + path)
|
||||||
return []
|
return []
|
||||||
regObj = re.compile(searchRegex)
|
searchRegex = searchRegex.strip()
|
||||||
|
# regObj = re.compile(searchRegex)
|
||||||
|
|
||||||
res = []
|
res = []
|
||||||
for root, dirs, fnames in os.walk(path):
|
for root, dirs, fnames in os.walk(path):
|
||||||
for fname in fnames:
|
for fname in fnames:
|
||||||
filePath = os.path.join(root, fname)
|
filePath = os.path.join(root, fname)
|
||||||
with open(filePath, 'r') as file:
|
with open(filePath, 'r') as postFile:
|
||||||
data = file.read()
|
data = postFile.read()
|
||||||
if not regObj.match(data):
|
# if not regObj.match(data):
|
||||||
continue
|
if searchRegex not in data:
|
||||||
|
continue
|
||||||
|
|
||||||
res.append(filePath)
|
res.append(filePath)
|
||||||
if len(res) >= maxResults:
|
if len(res) >= maxResults:
|
||||||
return res
|
return res
|
||||||
|
|
Loading…
Reference in New Issue