Issue #2919: fix — look for a file named post.json in the list’s landing folder and...
authorSteven Black <redacted>
Sun, 13 Jul 2025 02:53:37 +0000 (22:53 -0400)
committerSteven Black <redacted>
Sun, 13 Jul 2025 02:53:37 +0000 (22:53 -0400)
post.json [new file with mode: 0644]
updateHostsFile.py

diff --git a/post.json b/post.json
new file mode 100644 (file)
index 0000000..838ae9f
--- /dev/null
+++ b/post.json
@@ -0,0 +1,8 @@
+{
+  "filters": [
+    "allegro",
+    "bilet",
+    "-pl",
+    "npost"
+  ]
+}
index a350fe867ef394c973fce3311bda0b24fd657dec..6d59fdbb76b6a2b0d7be849b44496bb27d0a365d 100755 (executable)
@@ -951,6 +951,17 @@ def remove_dups_and_excl(mergefile, exclusionregexes, outputfile=None):
     else:
         finalfile = outputfile
 
+    # analyze any post.json here
+    post_json_path = os.path.join(os.path.dirname(finalfile.name), "post.json")
+    filters = []
+    if os.path.isfile(post_json_path):
+        try:
+            with open(post_json_path, "r", encoding="UTF-8") as post_file:
+                post_data = json.load(post_file)
+                filters = post_data.get("filters", [])
+        except Exception as e:
+            print_failure(f"Error reading post.json: {e}")
+
     mergefile.seek(0)  # reset file pointer
     hostnames = {"localhost", "localhost.localdomain", "local", "broadcasthost"}
     exclusions = settings["exclusions"]
@@ -961,6 +972,10 @@ def remove_dups_and_excl(mergefile, exclusionregexes, outputfile=None):
         # Explicit encoding
         line = line.decode("UTF-8")
 
+        # Apply post.json filters
+        if filters and any(f in line for f in filters):
+            continue
+
         # replace tabs with space
         line = line.replace("\t+", " ")
 
git clone https://git.99rst.org/PROJECT