From 4c74d39df0d0479b96d8c8bcf7a40b3fac1f4331 Mon Sep 17 00:00:00 2001 From: dgtlmoon Date: Sun, 12 Mar 2023 18:11:53 +0100 Subject: [PATCH] Code - Abstract out the diff fetch types to make it easier to integrate new ones (#1467) --- changedetectionio/fetchers/__init__.py | 0 .../{fetch_site_status.py => fetchers/text_json_diff.py} | 2 ++ changedetectionio/tests/test_element_removal.py | 1 - changedetectionio/tests/test_ignore_regex_text.py | 4 +--- changedetectionio/tests/test_ignore_text.py | 2 +- changedetectionio/update_worker.py | 5 ++--- 6 files changed, 6 insertions(+), 8 deletions(-) create mode 100644 changedetectionio/fetchers/__init__.py rename changedetectionio/{fetch_site_status.py => fetchers/text_json_diff.py} (99%) diff --git a/changedetectionio/fetchers/__init__.py b/changedetectionio/fetchers/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/changedetectionio/fetch_site_status.py b/changedetectionio/fetchers/text_json_diff.py similarity index 99% rename from changedetectionio/fetch_site_status.py rename to changedetectionio/fetchers/text_json_diff.py index 04b57367..9faea305 100644 --- a/changedetectionio/fetch_site_status.py +++ b/changedetectionio/fetchers/text_json_diff.py @@ -1,3 +1,5 @@ +# HTML to TEXT/JSON DIFFERENCE FETCHER + import hashlib import json import logging diff --git a/changedetectionio/tests/test_element_removal.py b/changedetectionio/tests/test_element_removal.py index 6f9e8879..093764f7 100644 --- a/changedetectionio/tests/test_element_removal.py +++ b/changedetectionio/tests/test_element_removal.py @@ -71,7 +71,6 @@ def set_modified_response(): def test_element_removal_output(): - from changedetectionio import fetch_site_status from inscriptis import get_text # Check text with sub-parts renders correctly diff --git a/changedetectionio/tests/test_ignore_regex_text.py b/changedetectionio/tests/test_ignore_regex_text.py index 2d12e7a6..e9b69a9f 100644 --- a/changedetectionio/tests/test_ignore_regex_text.py +++ b/changedetectionio/tests/test_ignore_regex_text.py @@ -1,7 +1,5 @@ #!/usr/bin/python3 -import time -from flask import url_for from . util import live_server_setup from changedetectionio import html_tools @@ -11,7 +9,7 @@ def test_setup(live_server): # Unit test of the stripper # Always we are dealing in utf-8 def test_strip_regex_text_func(): - from changedetectionio import fetch_site_status + from ..fetchers import text_json_diff as fetch_site_status test_content = """ but sometimes we want to remove the lines. diff --git a/changedetectionio/tests/test_ignore_text.py b/changedetectionio/tests/test_ignore_text.py index 14b92786..288dffc9 100644 --- a/changedetectionio/tests/test_ignore_text.py +++ b/changedetectionio/tests/test_ignore_text.py @@ -11,7 +11,7 @@ def test_setup(live_server): # Unit test of the stripper # Always we are dealing in utf-8 def test_strip_text_func(): - from changedetectionio import fetch_site_status + from ..fetchers import text_json_diff as fetch_site_status test_content = """ Some content diff --git a/changedetectionio/update_worker.py b/changedetectionio/update_worker.py index 5dc3f2eb..3dd1059c 100644 --- a/changedetectionio/update_worker.py +++ b/changedetectionio/update_worker.py @@ -4,8 +4,7 @@ import queue import time from changedetectionio import content_fetcher -from changedetectionio import queuedWatchMetaData -from changedetectionio.fetch_site_status import FilterNotFoundInResponse +from .fetchers.text_json_diff import FilterNotFoundInResponse # A single update worker # @@ -153,7 +152,7 @@ class update_worker(threading.Thread): os.unlink(full_path) def run(self): - from changedetectionio import fetch_site_status + from .fetchers import text_json_diff as fetch_site_status update_handler = fetch_site_status.perform_site_check(datastore=self.datastore)