Update: 2026-06-11 18:22:57
This commit is contained in:
47
transform_links.py
Normal file
47
transform_links.py
Normal file
@@ -0,0 +1,47 @@
|
||||
import sys
|
||||
import os
|
||||
|
||||
def transform(filepath):
|
||||
if not os.path.exists(filepath):
|
||||
print(f"File not found: {filepath}")
|
||||
return
|
||||
|
||||
with open(filepath, 'r') as f:
|
||||
lines = f.readlines()
|
||||
|
||||
new_lines = []
|
||||
for line in lines:
|
||||
stripped = line.strip()
|
||||
if stripped.startswith('static String ') or stripped.startswith('static final String ') or stripped.startswith('static const String '):
|
||||
if ' get ' in line or 'appDomain' in line:
|
||||
new_lines.append(line)
|
||||
continue
|
||||
|
||||
modified = line.replace('static final String ', 'static String ')
|
||||
modified = modified.replace('static const String ', 'static String ')
|
||||
|
||||
eq_index = modified.find('=')
|
||||
if eq_index != -1:
|
||||
before_eq = modified[:eq_index].rstrip()
|
||||
after_eq = modified[eq_index+1:]
|
||||
|
||||
parts = before_eq.split()
|
||||
var_name = parts[-1]
|
||||
parts.pop()
|
||||
|
||||
before_eq = ' '.join(parts) + ' get ' + var_name
|
||||
modified = before_eq + ' =>' + after_eq
|
||||
new_lines.append(modified)
|
||||
else:
|
||||
new_lines.append(line)
|
||||
|
||||
with open(filepath, 'w') as f:
|
||||
f.writelines(new_lines)
|
||||
print(f"Transformed {filepath}")
|
||||
|
||||
if __name__ == '__main__':
|
||||
if len(sys.argv) < 2:
|
||||
print("Usage: python3 transform_links.py <file>")
|
||||
else:
|
||||
for f in sys.argv[1:]:
|
||||
transform(f)
|
||||
Reference in New Issue
Block a user