feat: Add speed-up factor to recording timestamps in redact.py

This commit is contained in:
Paul Gauthier (aider) 2025-03-11 17:54:12 -07:00
parent 1bb3041298
commit a27f4d0e04

View file

@ -4,6 +4,9 @@ import sys
import os import os
import json import json
# Speed up factor for the recording
SPEEDUP = 1.25
def process_file(input_path, output_path): def process_file(input_path, output_path):
""" """
Process an asciinema cast v2 file to filter out certain sections based on ANSI cursor commands. Process an asciinema cast v2 file to filter out certain sections based on ANSI cursor commands.
@ -74,7 +77,8 @@ def process_file(input_path, output_path):
# Ensure timestamps never go backward # Ensure timestamps never go backward
adjusted_timestamp = max(adjusted_timestamp, last_timestamp) adjusted_timestamp = max(adjusted_timestamp, last_timestamp)
last_timestamp = adjusted_timestamp last_timestamp = adjusted_timestamp
record[0] = adjusted_timestamp # Apply speedup factor to the timestamp
record[0] = adjusted_timestamp / SPEEDUP
outfile.write(json.dumps(record) + '\n') outfile.write(json.dumps(record) + '\n')
# If we're in skip mode, check if we should exit it # If we're in skip mode, check if we should exit it
@ -102,7 +106,8 @@ def process_file(input_path, output_path):
# Ensure timestamps never go backward # Ensure timestamps never go backward
adjusted_timestamp = max(adjusted_timestamp, last_timestamp) adjusted_timestamp = max(adjusted_timestamp, last_timestamp)
last_timestamp = adjusted_timestamp last_timestamp = adjusted_timestamp
record[0] = adjusted_timestamp # Apply speedup factor to the timestamp
record[0] = adjusted_timestamp / SPEEDUP
outfile.write(json.dumps(record) + '\n') outfile.write(json.dumps(record) + '\n')
# Otherwise we're still in skip mode, don't write anything # Otherwise we're still in skip mode, don't write anything