Created
November 11, 2020 02:53
-
-
Save sqd/9bc7257c47016d679c9294ca8f06b4f7 to your computer and use it in GitHub Desktop.
normalize pager output
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import sys | |
import re | |
input_str = sys.stdin.read() | |
shell_pid = re.compile(r'vm_create\t\((\d+)').search(input_str).group(1) | |
shell_pid = shell_pid | |
pid_list = [shell_pid] | |
for match in re.finditer(r'vm_create\t\((\d+), (\d+)\)', input_str): | |
pid_list.append(match.group(2)) | |
sub = 0 | |
input_str = input_str.replace(f'({pid_list[0]}, {pid_list[1]})', '(0, 1)') | |
for pid in pid_list: | |
input_str = input_str.replace(f'({pid}', f'({sub}') | |
input_str = input_str.replace(f'{pid})', f'{sub})') | |
sub += 1 | |
sys.stdout.write(input_str) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment