-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfix_scaffolds.py
More file actions
38 lines (30 loc) · 1.92 KB
/
Copy pathfix_scaffolds.py
File metadata and controls
38 lines (30 loc) · 1.92 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
import os
import re
files_to_check = [
"app/src/main/java/com/example/rabit/ui/automation/InjectorScreen.kt",
"app/src/main/java/com/example/rabit/ui/automation/RemoteExplorerScreen.kt",
"app/src/main/java/com/example/rabit/ui/automation/ReverseShellScreen.kt",
"app/src/main/java/com/example/rabit/ui/automation/TerminalScannerScreen.kt",
"app/src/main/java/com/example/rabit/ui/automation/AutomationDashboardScreen.kt",
"app/src/main/java/com/example/rabit/ui/automation/AutoClickerScreen.kt",
"app/src/main/java/com/example/rabit/ui/airplay/AirPlayReceiverScreen.kt",
"app/src/main/java/com/example/rabit/ui/webbridge/WebBridgeScreen.kt",
"app/src/main/java/com/example/rabit/ui/assistant/AssistantScreen.kt"
]
def remove_scaffold(content):
# This regex tries to match the Scaffold block.
# It finds Scaffold(...) { padding -> and replaces it with nothing (or just the body).
# Removing just the topBar from these Scaffolds would be 100x safer and completely solves the "double app bar" issue without messing up closing braces!
# Wait, replacing topBar = { CenterAlignedTopAppBar(...) }, with nothing is much safer!
# Regex to carefully match topBar block inside Scaffold
new_content = re.sub(r'topBar\s*=\s*\{\s*(?:CenterAligned)?TopAppBar\([\s\S]*?(?=\n\s*(?:contentWindowInsets|snackbarHost|containerColor|floatingActionButton|bottomBar|modifier|\)\s*\{))\n?', '', content)
# If the file still has TopAppBar but it was the ONLY argument before ) { padding ->
# Let's write a targeted regex:
# Match `topBar = { ... CenterAlignedTopAppBar( ... ) ... },`
return new_content
for f in files_to_check:
print("Checking", f)
with open(f, "r") as file:
content = file.read()
# Easiest way to fix double app bars is literally just stripping the topBar = { ... } line completely.
# Let's just find the bounds of topBar = { ... } inside Scaffold.