aboutsummaryrefslogtreecommitdiff
path: root/updater/utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'updater/utils.py')
-rw-r--r--updater/utils.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/updater/utils.py b/updater/utils.py
new file mode 100644
index 0000000..bf54d0e
--- /dev/null
+++ b/updater/utils.py
@@ -0,0 +1,21 @@
+import logging
+
+
+def record_transformer(public_suffixes):
+ def transform(record):
+ name = record["name"]
+ suffixes = [suffix for suffix in public_suffixes if name.endswith(suffix)]
+ suffix = suffixes[0] if suffixes else None
+
+ if suffix:
+ logging.debug(f"stripping {suffix} from {name} as it is a public suffix")
+
+ record["name"] = name[: -len(suffix)]
+ record["internal"] = "off"
+ return record
+
+ logging.debug(f"keeping {name} as it is not a public suffix")
+ record["internal"] = "on"
+ return record
+
+ return transform