From 4ca229fd425832ddba045d2caa10a4408ca8d91e Mon Sep 17 00:00:00 2001 From: "Paul Gauthier (aider)" Date: Thu, 13 Mar 2025 16:19:31 -0700 Subject: [PATCH] refactor: Use regex to check for ordered "Atuin" characters in line --- scripts/redact-cast.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/scripts/redact-cast.py b/scripts/redact-cast.py index cbb7d8b74..081415c92 100755 --- a/scripts/redact-cast.py +++ b/scripts/redact-cast.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 import json import os +import re import sys import pyte @@ -35,7 +36,7 @@ def main(): # Track if we need to check the terminal (if "Atuin" might be on screen) check_terminal = False - atuin_chars = set("Atuin") + atuin_pattern = re.compile(r"A.*t.*u.*i.*n") # Process events line by line for line in tqdm(fin, desc="Processing events", total=total_lines - 1): @@ -43,9 +44,9 @@ def main(): continue # Fast initial check on raw line before JSON parsing - raw_line_has_atuin_chars = any(char in line for char in atuin_chars) + raw_line_has_atuin = bool(atuin_pattern.search(line)) - if raw_line_has_atuin_chars: + if raw_line_has_atuin: check_terminal = True # Only parse JSON if we're checking terminal or need to check