style: Format code with consistent quotes and spacing

This commit is contained in:
Paul Gauthier (aider) 2025-03-13 16:00:40 -07:00
parent 70d10a0bb2
commit dba5fb9dfa

View file

@ -6,47 +6,49 @@ import sys
import pyte import pyte
def main(): def main():
if len(sys.argv) != 3: if len(sys.argv) != 3:
print(f"Usage: {sys.argv[0]} input_cast_file output_cast_file") print(f"Usage: {sys.argv[0]} input_cast_file output_cast_file")
sys.exit(1) sys.exit(1)
input_file = sys.argv[1] input_file = sys.argv[1]
output_file = sys.argv[2] output_file = sys.argv[2]
# Initialize pyte screen and stream # Initialize pyte screen and stream
screen = pyte.Screen(80, 24) screen = pyte.Screen(80, 24)
stream = pyte.Stream(screen) stream = pyte.Stream(screen)
# Read and parse the cast file # Read and parse the cast file
with open(input_file, 'r') as f: with open(input_file, "r") as f:
# First line is header # First line is header
header = f.readline().strip() header = f.readline().strip()
# Read the events # Read the events
events = [json.loads(line) for line in f if line.strip()] events = [json.loads(line) for line in f if line.strip()]
filtered_events = [] filtered_events = []
# Process each event through the terminal emulator # Process each event through the terminal emulator
for event in events: for event in events:
# Process the event in the terminal # Process the event in the terminal
if len(event) >= 3 and event[1] == 'o': # Output event if len(event) >= 3 and event[1] == "o": # Output event
stream.feed(event[2]) stream.feed(event[2])
# Check if "Atuin" is visible on screen # Check if "Atuin" is visible on screen
display_content = "\n".join("".join(line) for line in screen.display) display_content = "\n".join("".join(line) for line in screen.display)
if "Atuin" in display_content: if "Atuin" in display_content:
continue # Skip this event continue # Skip this event
# Keep this event # Keep this event
filtered_events.append(event) filtered_events.append(event)
# Write the filtered content to the output file # Write the filtered content to the output file
with open(output_file, 'w') as f: with open(output_file, "w") as f:
f.write(header + '\n') f.write(header + "\n")
for event in filtered_events: for event in filtered_events:
f.write(json.dumps(event) + '\n') f.write(json.dumps(event) + "\n")
if __name__ == "__main__": if __name__ == "__main__":
main() main()