
import re

file_path = r'c:\Users\team_\Desktop\test_qwen\myproject\products\templates\products\productkit_edit.html'

try:
    with open(file_path, 'r', encoding='utf-8') as f:
        lines = f.readlines()
except FileNotFoundError:
    print(f"File not found: {file_path}")
    exit(1)

# Extract script part (approx lines 451 to 1321)
# Note: lines are 0-indexed in list
script_lines = lines[450:1322]
script_content = "".join(script_lines)

# Replace Django tags
# Replace {% ... %} with "TEMPLATETAG"
script_content = re.sub(r'\{%.*?%\}', '"TEMPLATETAG"', script_content)
# Replace {{ ... }} with "VARIABLE" or {} 
script_content = re.sub(r'\{\{.*?\}\}', '{}', script_content)

# Save to temp js file
temp_js_path = r'c:\Users\team_\Desktop\test_qwen\temp_check.js'
with open(temp_js_path, 'w', encoding='utf-8') as f:
    f.write(script_content)

print(f"Written to {temp_js_path}")
