diff options
author | Drew DeVault <sir@cmpwn.com> | 2019-06-07 11:53:42 -0400 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2019-06-07 11:54:01 -0400 |
commit | 6e61f58d8684ae8879482d371219d8ae5c00a39d (patch) | |
tree | 0df30b81471485779433e86457062a5cf2fcd0d2 /contrib/hldiff.py | |
parent | 0647ea64839df5ceecf3a71f672f05a589fd1409 (diff) | |
download | aerc-6e61f58d8684ae8879482d371219d8ae5c00a39d.tar.gz |
Rewrite Python filters in awk
Diffstat (limited to 'contrib/hldiff.py')
-rwxr-xr-x | contrib/hldiff.py | 37 |
1 files changed, 0 insertions, 37 deletions
diff --git a/contrib/hldiff.py b/contrib/hldiff.py deleted file mode 100755 index f3cfd202..00000000 --- a/contrib/hldiff.py +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/env python3 -from colorama import Fore, Style -import sys -import re - -stat_re = re.compile(r'(| \d+ )(\+*)(\-*)') -lines_re = re.compile(r'@@ (-\d+,\d+ \+\d+,\d+) @@') - -sys.stdin.reconfigure(encoding='utf-8', errors='ignore') -patch = sys.stdin.read().replace("\r\n", "\n") - -hit_diff = False -for line in patch.split("\n"): - if line.startswith("diff "): - hit_diff = True - print(f"{Style.BRIGHT}{line}{Style.RESET_ALL}") - continue - if hit_diff: - if line.startswith("-"): - print(f"{Fore.RED}{line}{Style.RESET_ALL}") - elif line.startswith("+"): - print(f"{Fore.GREEN}{line}{Style.RESET_ALL}") - elif line.startswith(" "): - print(line) - else: - if line.startswith("@@"): - line = lines_re.sub(f"{Fore.CYAN}@@ \\1 @@{Style.RESET_ALL}", - line) - print(line) - else: - print(f"{Style.BRIGHT}{line}{Style.RESET_ALL}") - else: - if line.startswith(" ") and "|" in line and ("+" in line or "-" in line): - line = stat_re.sub( - f'\\1{Fore.GREEN}\\2{Fore.RED}\\3{Style.RESET_ALL}', - line) - print(line) |