import pathlib
import re
import subprocess
import tempfile
def extract_and_migrate_sass(file_path):
"""Extracts
style_pattern = re.compile(r'', re.DOTALL)
# Extract all matching style blocks
matches = list(style_pattern.finditer(content))
if not matches:
print(f"No block
sass_content = match.group(1) # The content inside the '
# Replace the original style block with the new one
updated_content = updated_content.replace(original_style_block, new_style_block)
# Remove the temporary file
temp_file_path.unlink()
# Write the updated content back to the original file
with open(file_path, 'w', encoding='utf-8') as file:
file.write(updated_content)
print(f"Updated {file_path}")
def process_svelte_files(directory):
"""Recursively processes all .svelte files in the given directory."""
svelte_files = pathlib.Path(directory).rglob("*.svelte")
for svelte_file in svelte_files:
extract_and_migrate_sass(svelte_file)
def main():
"""Main function to process all .svelte files in the current directory."""
current_directory = pathlib.Path(__file__).parent
process_svelte_files(current_directory)
if __name__ == "__main__":
main()