diff --git a/ci/diff.py b/ci/diff.py index 9b8d9ae3..2582810b 100644 --- a/ci/diff.py +++ b/ci/diff.py @@ -7,8 +7,7 @@ import sys import urllib.parse from enum import StrEnum -from itertools import zip_longest -from typing import Any, Iterable +from typing import Any, Generator, Iterable, NamedTuple from rich import box from rich.console import Console, Group @@ -59,57 +58,6 @@ def __init__(self, expected: int, result: int) -> None: # noqa: D107 ) -def unquote_url(match: re.Match[str]) -> str: - """Unquote URL encoded text in a /api/v1/ URL.""" - return urllib.parse.unquote(match.group(0)) - - -def replace_url_id(match: re.Match[str]) -> str: - """Replace the final number (ID) in a URL with a placeholder.""" - # match.group(1) contains the part before the separator (`"url": "/api/...`) - # match.group(2) contains the separator (/ or =) - # match.group(3) contains the number we want to replace - # match.group(4) contains the closing double quote - return f"{match.group(1)}{match.group(2)}{match.group(4)}" - - -def group_objects(json_file_path: str) -> list[dict[str, Any]]: - """Group objects in a JSON file by a specific criterion. - - :param json_file_path: Path to the JSON file. - :returns: A list of grouped objects. - """ - with open(json_file_path, "r") as f: - s = f.read() - # Replace all URL encoded text in /api/v1/ URLs with unquoted text - # This lets us replace it down the line with our normal IPv{4,6} and MAC placeholders - # Must be done _before_ all other replacements - s = api_v1_pattern.sub(unquote_url, s) - - # Replace all non-deterministic values with placeholders - s = timestamp_pattern.sub("