From 702cb85df8798954737c93a4bd978d9a711ed343 Mon Sep 17 00:00:00 2001 From: Elizabeth Hunt Date: Thu, 11 Apr 2024 11:17:58 -0600 Subject: add acme script --- updater/utils.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 updater/utils.py (limited to 'updater/utils.py') 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 -- cgit v1.3