Browse Source

🎨 Auto format

pull/15327/head
pre-commit-ci-lite[bot] 3 months ago
committed by GitHub
parent
commit
84353509f0
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 12
      fix_snapshot.py

12
fix_snapshot.py

@ -1,10 +1,8 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
"""Remove the old snapshot dictionary from test_include_router_defaults_overrides.py""" """Remove the old snapshot dictionary from test_include_router_defaults_overrides.py"""
import re
# Read the file # Read the file
with open('tests/test_include_router_defaults_overrides.py', 'r') as f: with open("tests/test_include_router_defaults_overrides.py") as f:
lines = f.readlines() lines = f.readlines()
# Find and remove the old snapshot dictionary # Find and remove the old snapshot dictionary
@ -15,16 +13,16 @@ while i < len(lines):
new_lines.append(line) new_lines.append(line)
# If we hit operation_ids.add(op_id), the next non-empty line should be the start of the snapshot dict # If we hit operation_ids.add(op_id), the next non-empty line should be the start of the snapshot dict
if 'operation_ids.add(op_id)' in line: if "operation_ids.add(op_id)" in line:
# Skip all lines until we find the closing paren of snapshot() # Skip all lines until we find the closing paren of snapshot()
i += 1 i += 1
brace_count = 0 brace_count = 0
while i < len(lines): while i < len(lines):
cur_line = lines[i] cur_line = lines[i]
brace_count += cur_line.count('{') - cur_line.count('}') brace_count += cur_line.count("{") - cur_line.count("}")
# Check if this is the closing paren of snapshot() # Check if this is the closing paren of snapshot()
if brace_count == 0 and cur_line.strip() == ')': if brace_count == 0 and cur_line.strip() == ")":
i += 1 i += 1
break break
i += 1 i += 1
@ -33,7 +31,7 @@ while i < len(lines):
i += 1 i += 1
# Write back # Write back
with open('tests/test_include_router_defaults_overrides.py', 'w') as f: with open("tests/test_include_router_defaults_overrides.py", "w") as f:
f.writelines(new_lines) f.writelines(new_lines)
print("Done! Removed snapshot dictionary") print("Done! Removed snapshot dictionary")

Loading…
Cancel
Save