-
-
Notifications
You must be signed in to change notification settings - Fork 169
Expand file tree
/
Copy pathcmp.py
More file actions
32 lines (21 loc) · 800 Bytes
/
cmp.py
File metadata and controls
32 lines (21 loc) · 800 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import re
def remove_unchanged_attributes(plan: str) -> str:
"""
Remove unchanged attribute comments from plan text
"""
return '\n'.join(line for line in plan.splitlines() if not re.match(r'\s+# \(\d+ unchanged attributes hidden\)', line)).strip()
def remove_warnings(plan: str) -> str:
"""
Remove warnings from the plan text
"""
plan_lines = []
plan_summary_reached = False
for line in plan.splitlines():
if plan_summary_reached and (line.startswith('Warning') or line.startswith('╷')):
break
plan_lines.append(line)
if re.match(r'Plan: \d+ to \S+', line):
plan_summary_reached = True
return '\n'.join(plan_lines).strip()
def plan_cmp(a: str, b: str) -> bool:
return a.strip() == b.strip()