|
""" |
|
Script to update the README file with the metadata required by Hugging Face Spaces. |
|
""" |
|
|
|
|
|
requirements_path = "requirements.txt" |
|
|
|
with open(requirements_path, 'r', encoding='utf-16') as requirements: |
|
for line in requirements: |
|
if line.strip().startswith("streamlit=="): |
|
streamlit_version = line.strip().split('==')[1] |
|
break |
|
|
|
|
|
readme_path = "README.md" |
|
|
|
hf_space_metadata = f"""\ |
|
--- |
|
title: Chameleon |
|
emoji: 🦎 |
|
colorFrom: green |
|
colorTo: yellow |
|
sdk: streamlit |
|
sdk_version: {streamlit_version} |
|
app_file: src/app.py |
|
pinned: true |
|
--- |
|
""" |
|
|
|
|
|
with open(readme_path, 'r') as original_readme: |
|
data = original_readme.read() |
|
|
|
with open(readme_path, 'w', encoding="utf-8") as modified_readme: |
|
modified_readme.write(hf_space_metadata + data) |
|
|