-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfix-orphaned-process-lines.py
More file actions
63 lines (48 loc) · 2.57 KB
/
fix-orphaned-process-lines.py
File metadata and controls
63 lines (48 loc) · 2.57 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/env python3
import os
import re
features_dir = "/mnt/d/source/modelingevolution/streamer/src/zerobuffer/modules/harmony/ModelingEvolution.Harmony/Features"
def fix_feature_file(filepath):
with open(filepath, 'r') as f:
lines = f.readlines()
fixed_lines = []
i = 0
while i < len(lines):
line = lines[i]
# Check if this is an orphaned process line (just "Given/When/Then/And the 'reader/writer' process")
orphaned_pattern = r"^\s*(Given|When|Then|And|But)\s+the\s+'(reader|writer)'\s+process\s*$"
match = re.match(orphaned_pattern, line)
if match:
# Skip this orphaned line
i += 1
continue
# Fix steps that need process context
line = re.sub(r"^(\s*)(And|When)\s+write\s+frame", r"\1\2 the 'writer' process writes frame", line)
line = re.sub(r"^(\s*)(And|When)\s+read\s+frame", r"\1\2 the 'reader' process reads frame", line)
line = re.sub(r"^(\s*)(And|When)\s+signal\s+space", r"\1\2 the 'reader' process signals space", line)
line = re.sub(r"^(\s*)(And|When)\s+attempt\s+to\s+write", r"\1\2 the 'writer' process attempts to write", line)
line = re.sub(r"^(\s*)(And|When)\s+write\s+should", r"\1\2 the 'writer' process write should", line)
line = re.sub(r"^(\s*)(And|When)\s+fill\s+buffer", r"\1\2 the 'writer' process fills buffer", line)
line = re.sub(r"^(\s*)(And|When)\s+continue\s+filling", r"\1\2 the 'writer' process continues filling", line)
line = re.sub(r"^(\s*)(And|Then)\s+attempt\s+to\s+connect", r"\1\2 another writer attempts to connect", line)
line = re.sub(r"^(\s*)(And|Then)\s+connection\s+should", r"\1\2 the connection should", line)
line = re.sub(r"^(\s*)(And|When)\s+read\s+all\s+frames", r"\1\2 the 'reader' process reads all frames", line)
fixed_lines.append(line)
i += 1
# Join lines and clean up
content = ''.join(fixed_lines)
# Clean up any double blank lines
content = re.sub(r'\n\n\n+', '\n\n', content)
# Ensure file ends with newline
if not content.endswith('\n'):
content += '\n'
with open(filepath, 'w') as f:
f.write(content)
return True
# Process all feature files
for filename in os.listdir(features_dir):
if filename.endswith('.feature'):
filepath = os.path.join(features_dir, filename)
print(f"Processing {filename}...")
fix_feature_file(filepath)
print("Done!")