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 ") else: for f in sys.argv[1:]: transform(f)