Issue #14 - Tweaks to edit, create ignore text, tests for ignore text, integrate ignore text

This commit is contained in:
Leigh Morresi
2021-02-26 20:07:26 +01:00
parent 0855017dca
commit 468184bc3a
8 changed files with 213 additions and 16 deletions

View File

@@ -11,6 +11,15 @@ class perform_site_check():
super().__init__(*args, **kwargs)
self.datastore = datastore
def strip_ignore_text(self, content, list_ignore_text):
output=[]
for line in content.splitlines():
if not any(skip_text in line for skip_text in list_ignore_text):
output.append(line)
return "\n".join(output)
def run(self, uuid):
timestamp = int(time.time()) # used for storage etc too
stripped_text_from_html = False
@@ -76,7 +85,16 @@ class perform_site_check():
if not len(r.text):
update_obj["last_error"] = "Empty reply"
fetched_md5 = hashlib.md5(stripped_text_from_html.encode('utf-8')).hexdigest()
content = stripped_text_from_html.encode('utf-8')
# If there's text to skip
# @todo we could abstract out the get_text() to handle this cleaner
if len(self.datastore.data['watching'][uuid]['ignore_text']):
content = self.strip_ignore_text(content, self.datastore.data['watching'][uuid]['ignore_text'])
fetched_md5 = hashlib.md5(content).hexdigest()
# could be None or False depending on JSON type
if self.datastore.data['watching'][uuid]['previous_md5'] != fetched_md5: