import os readme_path = 'rl_code_fix_env/README.md' with open(readme_path, 'r', encoding='utf-8') as f: text = f.read() # Strip any existing YAML header if present, then add the clean one parts = text.split('---') if len(parts) >= 3: body = '---'.join(parts[2:]) else: body = text header = """--- title: Rl Code Fix Env emoji: 🚀 colorFrom: green colorTo: purple sdk: docker dockerfile: server/Dockerfile app_port: 8000 pinned: false --- """ new_content = header + body.strip() + "\n" # Write with Unix line endings with open(readme_path, 'wb') as f: f.write(new_content.encode('utf-8').replace(b'\r\n', b'\n'))