File size: 887 Bytes
c309f22
 
 
 
 
 
 
 
 
 
 
 
ec2ecb9
c309f22
ec2ecb9
 
057fb29
ec2ecb9
 
 
 
 
 
c309f22
ec2ecb9
 
 
 
 
 
c309f22
 
ec2ecb9
057fb29
c309f22
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
"""
Script to update the README file with the metadata required by Hugging Face Spaces.
"""

# Get Streamlit Version
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

# Update README
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
---
"""

# Open the README file
with open(readme_path, 'r') as original_readme:
    data = original_readme.read()
# Rewrite the README file, with metadata prepended
with open(readme_path, 'w', encoding="utf-8") as modified_readme:
    modified_readme.write(hf_space_metadata + data)